I'm trying to generate python thread(s) in NEURON in order to communicate to a model directly.
My working environment is
NEURON version 7.3 (586:68e542bbe5b7)
Python 2.7.1+ (r271:86832)
Linux 2.6.35-22 (Ubuntu SMP)
I made a simple hoc file and a python file:
Code: Select all
//test.hoc
nrnpython("import time")
nrnpython("import test")
Code: Select all
//test.py
import threading
import datetime
import time
class ThreadTest(threading.Thread):
total = 0
def run(self):
while True:
now = datetime.datetime.now()
self.total += 1
print "%s : I'm working at : %s %d" % (self.getName(), now, self.total)
time.sleep(3)
t = ThreadTest()
s = ThreadTest()
t.start()
s.start()
$nrniv -python
>>>import test
It worked with no problem. Two threads printed messages continuously.
Then, I ran the codes with the hoc interpreter.
$nrniv
oc>nrnpython("import test")
Two threads printed their messages once. After then, they didn't seem to want to do anything. I fed the following:
oc>nrnpython("time.sleep(1)")
They printed only once again. So I tried to terminate NEURON with quit(). Then the threads started to work normally. But I couldn't return back to the prompt (oc>) of hoc interpreter. Finally, I had to use Ctrl + 'z' to escape.
Does anybody know how to run python threads with the hoc interpreter?
Thanks in advance.