Comments (10)
Yup, also hangs here. Only for standard strategies, cheaters and basic go through fine. I am not versed well enough with the code in #122 to tell what the matter is.
from axelrod.
Now I see you are using multiprocessing
. My first guess: deadlock caused by a large queue.
from axelrod.
let me tag @meatballs just in case he hasn't seen this...
from axelrod.
I think the problem here, as @langner says, is a deadlocked multiprocessing queue. Specifically, it's the 'done' queue.
I think the problem has been there all along. If you look at lines 92-95 of tournament.py:
# There is a 0.5 second timeout here as the all_strategies tournament
# occasionally hangs the join method for some strange reason.
for process in processes:
process.join(0.5)
I had to add a timeout to deal with the occasional hang on my machine. That timeout simply causes the process to terminate early and, although it stops the hang, it means the results are mostly an empty matrix. Increasing the the timeout to something like 60s hides the problem completely, but doesn't solve it!
I think the combination of the deterministic cache being passed by #122, the extra strategies added by #121 and the removal of the timeout in #122 have combined to bring the problem to a head.
The crux of the problem is that multiprocessing can't cope with the size of output queue that we are creating. Even setting the queue's maxsize property to 0 (supposedly infinite) doesn't solve the problem.
It might be worth looking at using threading instead of multiprocessing.
from axelrod.
Another potential solution might be to kick off a daemon process first which reads from the done queue and appends to the payoffs list.
from axelrod.
Seems I've fallen for a well known gotcha: https://docs.python.org/2/library/multiprocessing.html#all-platforms
Bear in mind that a process that has put items in a queue will wait before terminating until all the buffered items are fed by the “feeder” thread to the underlying pipe. (The child process can call the cancel_join_thread() method of the queue to avoid this behaviour.)
This means that whenever you use a queue you need to make sure that all items which have been put on the queue will eventually be removed before the process is joined. Otherwise you cannot be sure that processes which have put items on the queue will terminate. Remember also that non-daemonic processes will be joined automatically.
An example which will deadlock is the following:
from multiprocessing import Process, Queue def f(q): q.put('X' * 1000000) if __name__ == '__main__': queue = Queue() p = Process(target=f, args=(queue,)) p.start() p.join() # this deadlocks obj = queue.get()
A fix here would be to swap the last two lines (or simply remove the p.join() line).
from axelrod.
I think I have this fixed. Branch 125 in my repo. I'm still testing it out.
from axelrod.
Works fine for me!
from axelrod.
A relevant SO thread: http://stackoverflow.com/questions/21641887/python-multiprocessing-process-hangs-on-join-for-large-queue (there are also others)
from axelrod.
Fixed by #127
from axelrod.
Related Issues (20)
- Reorganisation of documentation. HOT 3
- Reorganisation ? of cheating strategies
- Add a citation.cff file HOT 6
- Links to contributing guide broken by docs restructure
- CI failing due to typing issues HOT 3
- Implement asymmetric games HOT 6
- Game classification HOT 4
- Implement abstract games more fully (5.0.0)
- Restructure strategies folder HOT 4
- Documentation for 5.0.0
- Simplify/move the `ResultSet` HOT 1
- Expressing in a formal logical language HOT 2
- You may have missed some details in your code HOT 1
- I couldn't find the strategy submitted by Mauk in the competition for 19th place HOT 2
- If I want to test the first tournament, what should I do based on your code? HOT 2
- Do you know the source code of the first tournament? HOT 2
- axelrod.plot.Plot may be incompatible with recent Pandas udpates HOT 2
- Change the TFT in the first tournament HOT 3
- High-noise Tournament for comparison HOT 1
- Supporting Python 3.12 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axelrod.