Comment 4 for bug 710405

Revision history for this message
Jason Gerard DeRose (jderose) wrote :

Wow, after over 2 months, I finally have this fixed. Something weird is going on with desktopcouch get_oauth_tokens() in that it's returning a different value when called from a DBus service launched with Popen. This was all happing in unit tests only, not something that comes up during normal use. Steps:

1. In `setup.py` process, call get_oauth_tokens(), delete 'test_dmedia' database if it exists

2. Start `dmedia-service` or `dmedia-importer-service` with Popen, which will themselves call get_oauth_tokens(), but the value will be different than in (1)

3. Kill (2) and again start `dmedia-service` or `dmedia-importer-service` with Popen, they call get_oauth_tokens(), and the value will yet again be different... different than (2), still not equal to (1)

I'll try to cook up a minimal script to demo this behaviour outside of dmedia, against desktopcouch only.

I stumbled across the solution during the great refactor of 2011 [1]. As both `dmedia-service` and `dmedia-importer-service` can now take an --env arg with the JSON serialized environment, I pass them the env that was created in the `setup.py` process... the services then use the oauth tokens retrieved in the main process, don't themselves call get_oauth_tokens()

[1] Great refactor of 2011 - https://bugs.launchpad.net/dmedia/+bug/753260