Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file lock to support xdist -n options #155

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

jsn1993
Copy link
Contributor

@jsn1993 jsn1993 commented Aug 25, 2016

Previously the reason why verilog import with -n option fails is that creating and checking the tmp file is not atomic. It is possible for two threads to create the tmp file at the same time (but only one file) and after one thread deletes the tmp file the other thread cannot find it.

Basically I wrap the code fragment that manipulates files with a fcntl file lock for verilog import and systemc import.

I also add -n option to Travis CI to show the performance difference.

The temp_file is generated by verilog import function and might be
manipulated at the same time when doing py.test -n X provided by
xdist. To protect the critical section, a simple way is to use
fcntl file lock.

See http://stackoverflow.com/questions/9907616/python-fcntl-does-not-lock-as-expected
This is to guarantee the release of the file lock. Otherwise, the
test will stuck.
@cbatten
Copy link
Contributor

cbatten commented Aug 25, 2016

We probably need to fix the tests that are failing TravisCI before merging this pull request, right? This can probably wait until next week while we get lab1 out.

@jsn1993
Copy link
Contributor Author

jsn1993 commented Aug 25, 2016

Interesting, it didn't fail locally. I need to reproduce that failure ...

@dmlockhart
Copy link
Contributor

I think you might want to try pytest fixtures:
http://doc.pytest.org/en/latest/fixture.html

They ensure a test suite that has shared resources only creates that resource once at test collection time and then all the tests could use the same generated Verilog. This will be especially helpful for large blocks that take a long time to verilate/compile.

Might be good to try pytest fixtures combined with some checking logic in verilator_sim.py that has better Exception checking if when accessing the file in an unexpected state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants