I created a PR for a new request events hook at https://github.com/devpi/devpi/pull/692 The problem with the current hooks devpiserver_stage_created, devpiserver_on_changed_versiondata and devpiserver_on_upload is that they are database events. That means when data is imported or replicated, they are called again. That is also why they don't have access to the request and thus infos like the logged in user. The devpiserver_on_upload_sync is called from within the request, but it may be called prematurely, because the current transaction wasn't commited and there could be an error. There is also a possible race condition due to that, because the file may not be accessible when the triggered plugin does something. Again the infos the hook currently gets is limited as well. In the proposed implementation the event handlers are called after the data was sent to the client. This was done to ensure a plugin won't block normal operation. The client always gets the result of the request first. The downside is that when the client needs a long time to fetch the response, the event handlers are delayed. It might be useful to call the handlers in a separate thread while the client is served. Comments on this are welcome. For now I wanted to avoid the added complexity. Another change from the old hooks is, that it is possible an event handler isn't called. This only happens when devpi-server is stopped after commit, but before the event handlers were called. I consider this a minor issue, but again, comments on this are welcome. Regards, Florian Schulze
participants (1)
-
Florian Schulze