dgovil / PySignal

A purely Python implementation of the Qt signal system with no QObject dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Threading support, queued Signal connections

melevine opened this issue · comments

Firstly, this project is super cool, thanks for tackling this!

Looking through your tests and code, I don't see much in regards to threading support, or implications of using signals for thread communication. At least in Qt, I see that as a major feature of Signals and Slots. The ability to send a signal/message to a thread and have that message queue is a pretty awesome feature. While I don't see explicit support for this, it's possible that "it just works." If that's the case, it would be great to see some examples of it's usage in a threading context.

Hi!
Currently there isn't any threading support. Everything is called in the same thread as the signal is emitted from. I'll add that caveat to the ReadMe for now

I think threading support like Qt has would be great, it just seems like it would be complex to support in just Python without needing a base object like a QObject like Qt uses.

I'll need to do some research when I get some free time into how to mimic the behavior for threading.
If you have any ideas or anyone does really, I'm all ears though!

For reference sake here for me (or someone else) in the future is a description of Qt's threading support regarding signals
http://doc.qt.io/qt-4.8/threads-qobject.html

I have an implementation of Signals that may, or may not, be interesting to you. I made a basic example doing some async web requests with it here. I want to look into adding event loops to be able to facilitate the queued system at some point, but I've been busy recently :(

@Ahuge Interesting! Thanks for sharing that.

Maybe I'm misunderstanding your code though, but it still functions within a single thread right? Async ops run in the same thread as the thread they were launched from so it should function fine there, but the signals might fail if doing cross thread calling?