Closed Bug 1626086 Opened 5 years ago Closed 5 years ago

Python: Provide a way to make sure pings are sent before application exits

Categories

(Data Platform and Tools :: Glean: SDK, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Assigned: mdroettboom)

References

Details

Attachments

(1 file)

I noticed last Friday that if the application exits before the Glean thread in a python application has a chance to complete, a ping might not get sent. This can easily happen in mozregression or any command-line application where the ping is sent near the end of a process lifetime.

We should probably provide some mechanism to allow blocking application exit until things are sent (not sure if it should be enabled automatically or not).

We discussed this a bit on the Glean channel last Friday, one current hack you can try to get this effect is:

glean._dispatcher.Dispatcher._task_worker._queue.join()

... but that seems quite liable to break.

Flags: needinfo?(mdroettboom)
Blocks: 1581647
Priority: -- → P3
Whiteboard: [telemetry:glean-rs:m?]

(In reply to William Lachance (:wlach) (use needinfo!) from comment #0)

We should probably provide some mechanism to allow blocking application exit until things are sent (not sure if it should be enabled automatically or not).

The next iteration of the SDK will provide a bit more flexibility about the upload scheduling mechanism. This problem could be tackled as part of that bigger effort.

I'm not sure blocking on network automatically is a good idea, but maybe the python bindings could do something as the pingsender on Windows? i.e. when the application process is about to die (if we can detect that) we spin up an upload process.

Assignee: nobody → mdroettboom
Flags: needinfo?(mdroettboom)
Summary: Provide a way to make sure pings are sent before application exits → Python: Provide a way to make sure pings are sent before application exits

I think this should be tackled in two parts:

  • Add an atexit handler to just wait a while for the worker thread to complete. This will get handle most cases when things are working well and the network is up, etc. That's basically what PR 798 does.

  • Move ping uploading (just the networking part) to its own process. This is the part that's most likely to have long delays. This could then be fired off at shutdown allowing the main process to exit quickly. I think this is mildly blocked by bug 1605078 to move the networking handling to Rust -- not truly blocked, but it will end up looking very different after that and maybe best not to build it twice.

Priority: P3 → P1
Whiteboard: [telemetry:glean-rs:m?]
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: