On 26 October 2010 21:53, Mateusz Korniak <[email protected]> wrote:
> On Tuesday 26 of October 2010, Graham Dumpleton wrote:
>> On Tuesday, October 26, 2010, matkor <[email protected]> wrote:
>> > I would like to delegate some actions  (like storing data, sending e-
>> > mails etc ) after moment when my wsgi app have returned content via
>> > wsgi interface.
>> > How can this be implemented ?
>> > Using mod_python I could have used IIRC cleanup handler which was
>> > called after returning content to web browser.
>>
>> For a start read:
>> http://code.google.com/p/modwsgi/wiki/RegisteringCleanupCode
>> (...)
>> > I was thinking about adding another thread, but I have problem in
>> > stability during restarts ('daemon' mode)
>>
>> What problem?
>
> apache pid process SEGFAULTed on exit.
> But now with terminating and joining thread in atexit.register(cleanup)
> problem seems to be gone.

Yeah, if background thread running in C extension module a lot, can
cause problems like that.

For another take on ensuring a background thread shutdown, see:

  
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Monitoring_For_Code_Changes

In that code, rather than use sleep(), waits on Queue with timeout and
the atexit registered handler puts something on queue to make thread
exit.

> Is it intentional that printing in atexit.registered functions does not end up
> in error logs like other prints (at least during imports) ?

Ensure you are checking both main Apache server log and virtual host
error log. Depending on whether you are using embedded mode or daemon
mode and in the latter whether WSGIDaemonProcess inside of VirtualHost
dictates where it goes.

Graham

> I see raised exceptions properly though ...
>
> Big thanks for great help, regards,
>
> --
> Mateusz Korniak
>
> --
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/modwsgi?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to