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

Strange race condition with %attach #27

Open
embray opened this issue Nov 6, 2018 · 0 comments
Open

Strange race condition with %attach #27

embray opened this issue Nov 6, 2018 · 0 comments

Comments

@embray
Copy link
Contributor

@embray embray commented Nov 6, 2018

Frequently, if I try to %attach a .pyx or .spyx file in the console, most of the time I just get something like:

sage: %attach foo.spyx
Compiling ./foo.spyx...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-263e7c85293a> in <module>()
----> 1 get_ipython().magic(u'attach foo.spyx')

/opt/sagemath-8.4/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2158         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2159         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2160         return self.run_line_magic(magic_name, magic_arg_s)
   2161
   2162     #-------------------------------------------------------------------------

/opt/sagemath-8.4/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2079                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2080             with self.builtin_trap:
-> 2081                 result = fn(*args,**kwargs)
   2082             return result
   2083

<decorator-gen-115> in attach(self, s)

/opt/sagemath-8.4/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189
    190         if callable(arg):

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/repl/ipython_extension.pyc in attach(self, s)
    156             sage: shell.quit()
    157         """
--> 158         return self.shell.ex(load_wrap(s, attach=True))
    159
    160     @line_magic

/opt/sagemath-8.4/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in ex(self, cmd)
   2421         """Execute a normal python statement in user namespace."""
   2422         with self.builtin_trap:
-> 2423             exec(cmd, self.user_global_ns, self.user_ns)
   2424
   2425     def ev(self, expr):

<string> in <module>()

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/repl/load.pyc in load(filename, globals, attach)
    265         if attach:
    266             add_attached_file(fpath)
--> 267         exec(load_cython(fpath), globals)
    268     elif ext == '.f' or ext == '.f90':
    269         from sage.misc.inline_fortran import fortran

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/repl/load.pyc in load_cython(name)
     65     """
     66     from sage.misc.cython import cython
---> 67     mod, dir = cython(name, compile_message=True, use_cache=True)
     68     import sys
     69     sys.path.append(dir)

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/misc/cython.pyc in cython(filename, verbose, compile_message, use_cache, create_local_c_file, annotate, sage_namespace, create_local_so_file)
    619                         quiet=(verbose <= 0),
    620                         errors_to_stderr=False,
--> 621                         use_listing_file=True)
    622             finally:
    623                 # Read the "listing file" which is the file containing

/opt/sagemath-8.4/local/lib/python2.7/site-packages/Cython/Build/Dependencies.pyc in cythonize(module_list, exclude, nthreads, aliases, quiet, force, language, exclude_failures, **options)
    895         exclude_failures=exclude_failures,
    896         language=language,
--> 897         aliases=aliases)
    898     deps = create_dependency_tree(ctx, quiet=quiet)
    899     build_dir = getattr(options, 'build_dir', None)

/opt/sagemath-8.4/local/lib/python2.7/site-packages/Cython/Build/Dependencies.pyc in create_extension_list(patterns, exclude, ctx, aliases, quiet, language, exclude_failures)
    775             raise TypeError(msg)
    776
--> 777         for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
    778             if os.path.abspath(file) in to_exclude:
    779                 continue

/opt/sagemath-8.4/local/lib/python2.7/site-packages/Cython/Build/Dependencies.pyc in nonempty(it, error_msg)
    100         yield value
    101     if empty:
--> 102         raise ValueError(error_msg)
    103
    104

ValueError: '/home/sage/.sage/temp/NAVI-Brick/20396/spyx/_home_sage_foo_spyx/_home_sage_foo_spyx_3.pyx' doesn't match any files

But then every now and then it "just works" as expected. So I suspect there is some kind of race condition happening here: temporary files being cleaned up too quickly or something like that. I'm not exactly sure though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.