Sometimes ipcluster fails because the controller has not finished creating the FURL files
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
IPython |
Fix Released
|
Medium
|
Brian Granger |
Bug Description
The reason for this is that the FURL files that the controller write go through buffered IO and it is thus difficult to know when they are really there. But here is a nice solution:
> IO buffering issues are a common problem, the standard solution is:
> - write data to a temporary filename (in the same directory)
> - close the file
> - rename it to the final filename
Thanks! It just occurred to me that this standard pattern can be
nicely encapsulated, for python 2.5, in a context manager perhaps
called 'writefile' that would behave like a normal file object, except
that you do:
with writefile(
f.write(...)
...
and the context manager automatically takes care of:
- making the original file with a temp name
- closing the temp on exit and doing the rename
all of this transparently.
Related branches
- Fernando Perez: Needs Fixing
- Diff: None lines
Changed in ipython: | |
status: | Confirmed → Fix Committed |
Changed in ipython: | |
status: | Fix Committed → Fix Released |
I'm attaching a slightly documented version of the solution that implements the above pattern, as contributed by Neil Ludban <email address hidden> in the ipvision project. Thanks Neil!