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.

Handle multiple concurrent pip processes on the same environment

See original GitHub issue

I saw that pip 6 added file-based locking to the http cache to avoid multi-process contention. Something should be done to handle multiple packages being installed into the same virtualenv at the same time. For example if I had a concurrent makefile that installed independent foo_webapp1 and foo_webapp2 packages with a common dependency on foo_core, what would happen right now? What should happen? I guess the easiest is just to abort the second process.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:1
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pradyunsgcommented, Jun 6, 2022

Some of our tests for PEP 561 require pip to install packages, so we’re recently run into some instability in our test suite. Note that each copy of pip is installed in its own venv.

This should still work. Could you file an issue with the failure logs and a reproducer for the behaviour you’re seeing?

Multiple invocations of pip in separate environments should work already. That’s literally what pip’s own test suite does.

1reaction
ethanhscommented, Jun 5, 2022

In mypy we run our test suite in parallel. Some of our tests for PEP 561 require pip to install packages, so we’re recently run into some instability in our test suite. Note that each copy of pip is installed in its own venv. Sadly it seems that even with --cache-dir or --no-cache there is some race happening that seems to cause the tests to fail intermittently.

For now we will likely put a lock around package install, but it would be nice if @pradyunsg’s suggestion of throwing an error if pip is already running would be implemented, it would certainly have made it easier to discover what was going wrong with our tests 😃

What would the next steps be to get to concurrent pip? I imagine a list of all the places pip relies on global state would be a good start.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parallel Pip install - python - Stack Overflow
Parallel pip installation. This example uses xargs to parallelize the build process by approximately 4x. You can increase the parallelization factor with ...
Read more >
concurrent-log-handler - PyPI
Concurrent Log Handler (CLH) is designed to allow multiple processes to write to the same logfile in a concurrent manner. It is important...
Read more >
Speed Up Your Python Program With Concurrency
With multiprocessing , Python creates new processes. A process here can be thought of as almost a completely different program, though technically they're ......
Read more >
Python Multiprocessing: The Complete Guide
Each process follows the same life cycle. Understanding the stages of this life-cycle can help when getting started with concurrent programming ...
Read more >
Handling Concurrency Without Locks | Haki Benita
The problem with the naive implementation is that when multiple concurrent processes resolve the same short URL at the same time, the counter ......
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