Code Monkey home page Code Monkey logo

Comments (7)

AstraLuma avatar AstraLuma commented on May 28, 2024

(On POSIX, I'm just using a selector, which seems to be ok.)

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

The cross-platform solution is to have a background singleton that reads from all the pipes we care about and dispatch to the object that cares about it at the moment. (ie, the home-spun event loop option) Which will be fine until someone wants to coordinate those changes with something that can't be controlled the same way (eg, an external process).

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

Note: WaitForMultipleObjectsEx()

EDIT: Doesn't work on pipes.

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

PeekNamedPipe() does work on anonymous pipes, though.

EDIT: .fileno() returns some kind of emulated file descriptor with Unix-like semantics, not the actual windows handle. Oddly, Win32 calls want the handle, not the file descriptor.

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

The winvalve branch tries to use CancelSynchronousIo(). This doesn't work because CPython's .read() loops on the C read() call unless there's a Python exception and an interrupted flag is set. (Or the C read() not breaking, I didn't dig deep enough to tell the difference.)

The winvalve-peek branch tries to use PeekNamedPipe(), but fails due to the file descriptor emulation layer and the true win32 handles being hidden from us. (Basically, _pipe() vs CreatePipe())

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

Oh, and just as a reminder: These might need to be used with other things (standard IO, files, etc)

from slug.

AstraLuma avatar AstraLuma commented on May 28, 2024

So I think ReadFile()/CancelSyncronousIO() is the way to go on this, because it should support whatever kind of file-like that gets passed in. To avoid the file descriptor/handle issue, use _get_osfhandle() (Py). (Note that this handle is managed by the ms c runtime and should NOT be closed by slug. Slug should maintain a reference to the Python file object associated with the file descriptor and delete its copy of the handle before letting the file object fall out of scope.)

from slug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.