After adding the CLs:
- https://chromium-review.googlesource.com/362730
- https://chromium-review.googlesource.com/368531
Goofy unittest fails, due to rogue threads not stopping correctly after unittest execution.
Originally, none of the code in Goofy's unittest would call into test/shopfloor.py's DeleteDeviceData or UpdateDeviceData.
The above CLs store and retrieve serial numbers from DeviceData, which added calls to the above shopfloor.py functions throughout Goofy unittest run.
Turns out that there is a bug in both of DeleteDeviceData and UpdateDeviceData:
EventClient().post_event(Event(Event.Type.UPDATE_SYSTEM_INFO))
When an EventClient is created, it adds a "subscription" to Goofy's Event Queue, which is actually a Queue.Queue object. Until all of these subscriptions are removed, the Goofy Event Server will continue to run, waiting for events to send to its EventClients through their respective Queues.
If EventClient() is created and its object goes out of context, its Queue.Queue object remains in Goofy Event Server's "subscription" list indefinitely.
The correct usage of EventClient for posting a single event should be as follows:
with EventClient() as event_client:
event_client.post_event(...)
This ensures EventClient.close() gets called and removes the "subscription" from Goofy's Event Queue.
Comment 1 by bugdroid1@chromium.org
, Aug 29 2016