You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal is to make program handling http request and send them to Kafka. I use https://github.com/confluentinc/confluent-kafka-python library, which is syncronious. Thus, I have to implement infinitive loop flushing kafka queue in separate thread for each granian's worker. The loop runs while flag is_cancelled = False.
When I stop program (Ctrl-C, for example),
I expect granian will stop and somehow move to shutdown_app() function to give me possibility to set is_cancelled = True and stop infinite thread. Unfortunately, granian never stops, because infinite thread is included in granian worker process.
@vokson is that a WSGI application? For ASGI you can rely on the lifespan events to perform actions on shutdown.
Anyways, 1.4 will probably review signal handling and eventually add callbacks. In general, you can always customise what happens on the workers writing your own spawn method: for instance you can copy the code of _spawn_wsgi_worker (https://github.com/emmett-framework/granian/blob/master/granian/server.py#L284-L319) and add any code you want after the serve call (blocking til shutdown).
Granian 1.3.1
My goal is to make program handling http request and send them to Kafka. I use
https://github.com/confluentinc/confluent-kafka-python
library, which is syncronious. Thus, I have to implement infinitive loop flushing kafka queue in separate thread for each granian's worker. The loop runs while flagis_cancelled = False
.When I stop program (Ctrl-C, for example),
I expect granian will stop and somehow move to shutdown_app() function to give me possibility to set
is_cancelled = True
and stop infinite thread. Unfortunately, granian never stops, because infinite thread is included in granian worker process.If changed to
proc.join(1)', after 1 sec execution moves ahead and comes in
shutdown_app` function, then I can manage other stuff.Possible solution:
The text was updated successfully, but these errors were encountered: