gentnerlab / pyoperant

python package for operant conditioning
BSD 3-Clause "New" or "Revised" License
13 stars 15 forks source link

concurrent operation on audio file causes behavior to crash #112

Open MarvinT opened 8 years ago

MarvinT commented 8 years ago
"2016-04-08 09:50:46,982","ERROR","Unhandled exception: Traceback (most recent call last):
  File "/usr/local/anaconda/bin/behave", line 10, in <module>
    execfile(__file__)
  File "/local/home/bird/Code/pyoperant/scripts/behave", line 135, in <module>
    main()
  File "/local/home/bird/Code/pyoperant/scripts/behave", line 131, in main
    behavior.run()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/base.py", line 153, in run
    session=self._run_session)
  File "/local/home/bird/Code/pyoperant/pyoperant/utils.py", line 103, in run_state_machine
    state = state_functions[state]()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/base.py", line 215, in _run_session
    post=self.session_post)
  File "/local/home/bird/Code/pyoperant/pyoperant/utils.py", line 103, in run_state_machine
    state = state_functions[state]()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 205, in session_main
    run_trial_queue()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 162, in run_trial_queue
    self.run_trial()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 316, in run_trial
    self.response_main()
  File "/local/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 448, in response_main
    self.panel.speaker.stop()
  File "/local/home/bird/Code/pyoperant/pyoperant/hwio.py", line 115, in stop
    return self.interface._stop_wav()
  File "/local/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.py", line 95, in _stop_wav
    self.wf.close()
  File "/usr/local/anaconda/lib/python2.7/wave.py", line 183, in close
    self._i_opened_the_file.close()
IOError: close() called during concurrent operation on the same file object.
MarvinT commented 8 years ago

@neuromusic can you post a stack trace for one of your errors? I think I'm just going to suppress the exceptions because garbage collecting should deal with it automatically I think

neuromusic commented 8 years ago

Next time I get one I will

On Fri, Apr 8, 2016, 18:48 Marvin T notifications@github.com wrote:

@neuromusic https://github.com/neuromusic can you post a stack trace for one of your errors? I think I'm just going to suppress the exceptions because garbage collecting should deal with it automatically I think

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/gentnerlab/pyoperant/issues/112#issuecomment-207680670

neuromusic commented 8 years ago
ERROR at 2016-03-14 11:06:38,341:
Unhandled exception: Traceback (most recent call last):
  File "/usr/local/bin/behave", line 10, in <module>
    execfile(__file__)
  File "/home/bird/Code/pyoperant/scripts/behave", line 135, in <module>
    main()
  File "/home/bird/Code/pyoperant/scripts/behave", line 131, in main
    behavior.run()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/base.py", line 153, in run
    session=self._run_session)
  File "/home/bird/Code/pyoperant/pyoperant/utils.py", line 103, in run_state_machine
    state = state_functions[state]()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/base.py", line 215, in _run_session
    post=self.session_post)
  File "/home/bird/Code/pyoperant/pyoperant/utils.py", line 103, in run_state_machine
    state = state_functions[state]()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 198, in session_main
    run_trial_queue()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 164, in run_trial_queue
    self.run_trial()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 318, in run_trial
    self.response_main()
  File "/home/bird/Code/pyoperant/pyoperant/behavior/two_alt_choice.py", line 450, in response_main
    self.panel.speaker.stop()
  File "/home/bird/Code/pyoperant/pyoperant/hwio.py", line 115, in stop
    return self.interface._stop_wav()
  File "/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.py", line 95, in _stop_wav
    self.wf.close()
  File "/usr/lib/python2.7/wave.py", line 184, in close
    self._i_opened_the_file.close()
IOError: close() called during concurrent operation on the same file object.
MarvinT commented 8 years ago

so different spot in pyoperant, but stilli in the same spot in _stop_wav

I think I'm going to try just suppressing the exception... I'll add a logger and warning though