----- Oryginalna wiadomość ----- > Od: "C Anthony Risinger" <[email protected]> > Do: "uWSGI developers and users list" <[email protected]> > Wysłane: czwartek, 12 styczeń 2012 7:02:25 > Temat: Re: [uWSGI] after req hook > > so essentially you want the hook to run, period, regardless of how > the > worker ended, yes?
Yes. I want to "clean up" after work. Rollback or perform other operations, eg. own request counter. > > instead of endless hooks, what about a uWSGI-specific class of > exceptions? eg. `uwsgi.Exception.Harakiri` and whatever else? or an > class with a specific interface? It would be very nice to receive in a function that "ends work" wow work was completed / terminated. Cleaner in advance to know if the exception occurred, harakiri or if completed correctly. I think it's easier to just pass the paramter. Creating a class is cool, but I do not know how it is to the API in other languages. > or protocol, eg. __main__.__uwsgi_harakiri__, or > __main__.__uwsgi_worker_end__? maybe > then we can only register a single class/function when an external > event occurs, or in the case of protocols, not even need to register > anything at all (control moves to the nearest object in the stack > implementing the callable). > > ... i'm not knowledgeable enough about Python impl to know how > difficult or possible, but integrating these events/etc with the lang > allows flexibility without cluttering uwsgi, *and* potentially allows > finer-grained control over which callable actually handles the event > (vs. jumping to global function, maybe context/stack can be preserved > and/or resumed). > > thoughts? My goal is to perform some operations after worker job. For now, I do not need to recognize that the work was completed successfully or error. The only thing I care about what is to be made cleaning always after work. Currently, I capture the different types of exceptions (simple try), but not harakiri. after_req_hook - I solve this problem. But I see great potential for the future in the transfer as a parameter, how the work was finished: success, error, harakiri, etc. And often with the help of signals farm out hard work other workers. I would like to be able to "clean up" even after their work. Whether be done by reference to a function or class inheritance is irrelevant. If you are created a lot of hooks (__main__.__uwsgi_harakiri__, or __main__.__uwsgi_worker_end__) into each end of the separate. I would like to be an extra after them all. -- Łukasz Wróblewski http://www.nri.pl/ - Nowoczesne Rozwiązania Internetowe http://www.hostowisko.pl/ - Profesjonalny i tani hosting http://www.katalog-polskich-firm.pl/ - Najlepszy darmowy katalog firm _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
