Is blinker thread safe

98 views
Skip to first unread message

Neilen

unread,
Mar 9, 2012, 12:05:09 PM3/9/12
to discorporate-tools
Hi,

Is blinker thread safe? Presumably if you connect to a signal your
callback will be executed in the context of the thread that does the
send(), so your callback might need to do some locking, but is blinker
itself OK with the same signals being used by multiple threads?

Thanks
Neilen

jason kirtland

unread,
Mar 9, 2012, 2:44:51 PM3/9/12
to discorpor...@googlegroups.com
Hi Neilen,

Yes, blinker is designed to be thread safe.  Any number of threads can send() on the same signal in tandem with connects, disconnects & weakref disconnects on that signal without conflicts.

You're correct that callbacks are executed in the thread that calls send() and you may need to do locking in the callback or have the callback push work into a queue for a worker thread.

Cheers,
Jason


Neilen Marais

unread,
Mar 10, 2012, 3:01:16 AM3/10/12
to discorpor...@googlegroups.com
Hi,

On Fri, Mar 9, 2012 at 9:44 PM, jason kirtland <j...@discorporate.us> wrote:
>
> Hi Neilen,
>
> On Fri, Mar 9, 2012 at 9:05 AM, Neilen <nma...@gmail.com> wrote:
>>
>> Hi,
>>
>> Is blinker thread safe? Presumably if you connect to a signal your
>> callback will be executed in the context of the thread that does the
>> send(), so your callback might need to do some locking, but is blinker
>> itself OK with the same signals being used by multiple threads?
>
>
> Yes, blinker is designed to be thread safe.  Any number of threads can send() on the same signal in tandem with connects, disconnects & weakref disconnects on that signal without conflicts.

Thanks for the clear feedback. Now I can get to work :)

Cheers
Neilen

Reply all
Reply to author
Forward
0 new messages