Commit 1797ef49 authored by Jason Madden's avatar Jason Madden

Python 2.7 on Appveyor dies with a sharing violation; try mkstemp.

I can't reproduce with Python 2.7 locally, and the error makes no
sense (because we're writing the banner to a *brand bloody new* file,
guaranteed not to exist). So this is a shot in the dark.

See
https://ci.appveyor.com/project/denik/gevent/build/1.0.568/job/p44icqoi91a72e08.

Failed to rename 'c:\users\appveyor\appdata\local\temp\1\tmp_j5icn\gevent\corecext.pyx.tmp.2832' to 'c:\users\appveyor\appdata\local\temp\1\tmp_j5icn\gevent\corecext.pyx
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "util\cythonpp.py", line 31, in run
    self.value = target(*args)
  File "util\cythonpp.py", line 432, in _run_cython_on_file
    atomic_write(unique_pyx_filename, py_banner + value)
  File "util\cythonpp.py", line 902, in atomic_write
    os.rename(tmpname, filename)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
parent 2206505d
# Copyright (c) 2009-2012 Denis Bilenko. See LICENSE for details.
# This directive, supported in Cython 0.24+, causes sources files to be
# much smaller and thus cythonpp.py to be slightly faster. But it does make
# debugging more difficult.
# cython: emit_code_comments=False
cimport cython
cimport libev
from python cimport *
......
......@@ -890,14 +890,17 @@ class Str_sourceline(str):
return str(self), self.sourceline
def atomic_write(filename, data):
tmpname = filename + '.tmp.%s' % os.getpid()
with open(tmpname, 'w') as f:
dirname = os.path.dirname(os.path.abspath(filename))
tmpfd, tmpname = tempfile.mkstemp(dir=dirname, text=True)
with os.fdopen(tmpfd, 'w') as f:
f.write(data)
f.flush()
os.fsync(f.fileno())
if os.path.exists(filename):
os.unlink(filename)
dbg("Renaming %s to %s", tmpname, filename)
try:
os.rename(tmpname, filename)
except:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment