[Twisted-web] server crashes

stephan twisted-web@twistedmatrix.com
Tue, 24 Feb 2004 18:14:46 -0800


I see what you are saying: Python would throw an error in case of a 
conflictive access to a shared object.

Relating to your first suggestion: what do you excactly mean with calling 
twisted code in the main thread with reactor.callFromThread(func)? Can you 
give an example? When I retrieve my cookie should I do that with 
reactor.callFromThread(func)?

_stephan



On Tue, 24 Feb 2004 18:35:17 -0500, Christopher Armstrong 
<radix@twistedmatrix.com> wrote:

> stephan wrote:
>> I do use external libs, but they are all instanced within the thread. I
>> create a connection to a mysql dbm within each thread but that should
>> not cause any conflicts since each thread has its seperate connection
>> object.
>>
>> Personally I suspect the request object. Unfortunately I cannot just
>> deepcopy it and pass it to the thread.
>>
>> Is there an alternative way doing this? The only way I can imagine is to
>> do the threading later down the line which would make it harder to
>> maintain a version that also runs within apache.
>
> If you make _any_ calls to Twisted code, put them in a
> reactor.callFromThread(func). It runs the function in the main thread.
>
> But you shouldn't suspect the request object, because plain Python code
> won't make python simply die without error. Third party C code is almost
> always the culprit in stuff like that.
>