Electrostatics / APBS_Sphinx

APBS Rewrite
http://www.poissonboltzmann.org
1 stars 3 forks source link

File reader should error when it can't open a file #39

Open keith923 opened 8 years ago

keith923 commented 8 years ago

Currently when the file reader plugin is given a non-existent file it just hangs. When you hit ^C the following is printed to io.mc:

2016-07-07 11:51:25,658 Task exception was never retrieved
future: <Task finished coro=<ReadFile.run() done, defined at /Users/d3x923/Documents/projects/apbs/sphinx/plugins/ReadFile/plugin.py:118> exception=FileNotFoundError(2, 'No such file or directory') created at /Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py:135>
source_traceback: Object created at (most recent call last):
  File "apbs.py", line 109, in <module>
    sys.exit(main())
  File "apbs.py", line 100, in main
    coordinator.start(cmd, args, debug=debug)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py", line 99, in start
    exec(code, self._plugin_funcs, {'params':locals})
  File "example/run_pdb2pqr.apbs", line 3, in <module>
    pdb = read_file(params['pdb'])
  File "/Users/d3x923/Documents/projects/apbs/sphinx/plugins/ReadFile/plugin.py", line 77, in __init__
    super().__init__(**kwargs)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/plugin/base.py", line 104, in __init__
    self._task = self.runner.create_task(self.run())
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py", line 135, in create_task
    task = self._loop.create_task(func)
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/plugins/ReadFile/plugin.py", line 121, in run
    file = yield from self.open()
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/coroutines.py", line 206, in coro
    res = func(*args, **kw)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/plugins/ReadFile/plugin.py", line 102, in open
    return open(self._file, 'r')
FileNotFoundError: [Errno 2] No such file or directory: '1fas'
2016-07-07 11:51:25,660 Task was destroyed but it is pending!
source_traceback: Object created at (most recent call last):
  File "apbs.py", line 109, in <module>
    sys.exit(main())
  File "apbs.py", line 100, in main
    coordinator.start(cmd, args, debug=debug)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py", line 99, in start
    exec(code, self._plugin_funcs, {'params':locals})
  File "example/run_pdb2pqr.apbs", line 6, in <module>
    pdb.write_stdout()
  File "/Users/d3x923/Documents/projects/apbs/sphinx/plugins/WriteStdout/plugin.py", line 58, in __init__
    super().__init__(**kwargs)
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/plugin/base.py", line 104, in __init__
    self._task = self.runner.create_task(self.run())
  File "/Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py", line 135, in create_task
    task = self._loop.create_task(func)
task: <Task pending coro=<WriteStdout.run() done, defined at /Users/d3x923/Documents/projects/apbs/sphinx/plugins/WriteStdout/plugin.py:77> wait_for=<Future cancelled created at /usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py:252> cb=[_wait.<locals>._on_completion() at /usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py:414] created at /Users/d3x923/Documents/projects/apbs/sphinx/sphinx/core/coordinator.py:135>

There is an exception buried in there, and it's not being propagated. There is some magic to properly deal with exceptions when using asyncio.