> Hi, there.
> I was trying to use uWSGI signals to communicate between a programmed mule
> and the app's workers.
> I assumed that if the mule sent uwsgi.signal(MY_NUMBER, 'workers') then my
> handler would be executed once per worker. However, most of the time it's
> only executed once (I have two workers). Only *sometimes* both workers
> actually run the handler (the mule sleeps for a few seconds and then sends
> the signal again, some iterations work, some don't).
>
> I also tried registering different signals to different workers (still
> using the same handler); same result.
> i.e. I tried using (in a separate module loaded through shared-import):
>
> uwsgi.register_signal(1, 'workers', my_handler)
>
> or
>
> uwsgi.register_signal(1, 'worker1', my_handler)
> uwsgi.register_signal(2, 'worker2', my_handler)
>
> or annotating the handler with
>
> @signal(1, target='workers')
>
> No dice. I also tried sending the signal from the shared module instead of
> the mule, still same result.
> Am I misunderstanding something?
>
> (uWSGI 2.0.13.1, Python 2.7, OS X 10.11)
>
> Thanks in advance,
>
> Angelo
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
Hi, the right (low-level) procedure would be:
# register a signal that must be delivered to all workers (in a shared
imported module):
uwsgi.register_signal(num, 'workers', callable)
Then in your mule simply raise:
uwsgi.signal(num)
Can you try with a super simple example:
# the shared module
import uwsgi
def hello(signum):
print('Hello from worker %d' % uwsgi.worker_id())
uwsgi.register_signal(1, 'workers', hello)
# the mule
mport uwsgi
import time
while True:
time.sleep(1)
uwsgi.signal(1)
--
Roberto De Ioris
http://unbit.com
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi