question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongo-Observer ID Creation not Thread/Process Safe

See original GitHub issue

I often start multiple python my_experiment.py -m my_database in parallel (using subprocess.check_output). Every now and then two or more processes get the same ID in the MongoDB.

This is the basic script (without parameter setting, etc):

from multiprocessing.pool import ThreadPool as Pool
import subprocess

def run_configuration(_):
    subprocess.check_output('python build_model.py tmp ', shell=True)

with Pool(3) as pool:
    pool.map(run_configuration, 5*[None])

and the output will be

INFO - run_title - Running command 'command'
INFO - run_title - Running command 'command'
INFO - run_title - Started run with ID "427"
INFO - run_title - Started run with ID "427"
INFO - run_title - Running command 'command'
INFO - run_title - Started run with ID "428"

and I only end up with 2 entries in the database.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
f11rcommented, Feb 7, 2018

Seems to fix it. Thank you both!

1reaction
vnmabuscommented, Feb 6, 2018

I have submitted pull-request #254.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Observing an Experiment — Sacred 0.8.3 documentation
The first observer determines the _id of the run, or it can be set by the command line option --id . At the...
Read more >
MongoObserver fails to add metrics to run.info #739 - GitHub
I initially reported this issue with Omniboard where metrics were not showing up in the list of runs, but could be viewed just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found