[Twisted-Python] Twisted and Thread, thread not running when twisted app is running as service

Sereysethy TOUCH touch.sereysethy at gmail.com
Thu May 21 13:55:52 MDT 2020


Hi Jean-Paul,

I found the error after working on a short, self contained, correcte
example. It is not about twisted and normal thread in general, but
something else.

After more tests, I come to realise that whenever I instantiate this class
PolicyClient from this library
https://github.com/ray-project/ray/blob/master/rllib/env/policy_client.py in
my protocol or just anywhere, twisted app either freezes or terminates, and
this *only* happens when the app runs as a daemon, created using a service
(.tac file).

I hope you can take a look at the class PolicyClient, why it causes problem
to reactor main loop. Please point me to where the idea might come from.

I can give you the example but not sure if it is enough, as the client
needs to connect to a server.

Thank you,
TS


On Thu, May 21, 2020 at 5:23 PM Jean-Paul Calderone <
exarkun at twistedmatrix.com> wrote:

> On Thu, May 21, 2020 at 10:58 AM Sereysethy TOUCH <
> touch.sereysethy at gmail.com> wrote:
>
>> Hello,
>>
>> I am developing a twisted app, and it runs as a service using twistd -y
>> to start the app.
>> I am having a problem of running a thread. I know it is not recommended
>> to use thread, but the library that I use, the object created is running in
>> a thread.
>>
>> Here is the problem:
>>
>> 1) if I start reactor by running reactor.run() directly, thread is
>> running fine
>> 2) if I run it as a service using twisted, the thread is not running, it
>> runs but it seems to be blocked, because I tried to write something to file
>> using time.sleep(), but file is empty.
>>
>> Is there something that I miss? How can I debug this?
>>
>
> A good next step would be to create at Short, Self Contained, Correct
> (Compilable), Example <http://sscce.org/> and share it.
>
> Jean-Paul
>
>
>>
>> Thank you,
>>
>> TS
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200521/ba0612b3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: app.py
Type: text/x-python-script
Size: 1570 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20200521/ba0612b3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: service.tac
Type: application/octet-stream
Size: 172 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20200521/ba0612b3/attachment.obj>


More information about the Twisted-Python mailing list