Page 1 of 1

import neuron has side effects?

Posted: Wed Nov 17, 2010 10:15 pm
by aluchko
Unfortunately I can't post a concise test case since I'm having a lot of trouble with consistent reproducibility.

But I'd had a problem where I import some of my python code from hoc and end up having some trouble with the GUI. No errors or warnings show up, and the all hoc code after the python statement runs fine, but the panel associated with the code (created by a subsequent showopt call) simply doesn't show up.

I've narrowed it down to the python code calling "import neuron". Thus I have cases where I add the line
nrnpython("import neuron")
to my hoc code and do nothing else (I don't even call anymore python), and the panel doesn't show up. Are there some kind of side-effects going on when I import neuron that may be breaking the gui?

Note this isn't very reproducible, I've had a number of cases where I've thought I haven't changed anything and the bug simply vanishes for a while (on that note I'm running neuron straight from the repo and Ubuntu 10.10)

Re: import neuron has side effects?

Posted: Wed Nov 17, 2010 10:30 pm
by ted
aluchko wrote:I'm running neuron straight from the repo
Does this mean you obtained the latest development code from the mercurial repository, and built NEURON from that?

Re: import neuron has side effects?

Posted: Wed Nov 17, 2010 10:41 pm
by aluchko
ted wrote:
aluchko wrote:I'm running neuron straight from the repo
Does this mean you obtained the latest development code from the mercurial repository, and built NEURON from that?
My repo is based off of Tue Nov 02 12:23:11 2010 -0400
476:3ad72b90db90

I'll pull a newer repo tomorrow but I can't tonight as I just realized my source repo is on a machine that can't reach the outside world :/

Re: import neuron has side effects?

Posted: Thu Nov 18, 2010 9:19 am
by hines
So far things are too vague for me to form an opinion. The only condition I am aware of where there is a problem with the gui is when
one launches nrniv and in the python world invokes
from neuron import gui
That is intended only for launching python when the event loop is controlled by the python world instead of by InterViews. It starts a timer which
calls the InterViews event handler every 0.1 seconds. The problem is that when nrniv is launched, the InterViews event handler and hoc are already
running in thread 0, and suddenly calling the event handler from another thread can cause troubles.

Re: import neuron has side effects?

Posted: Thu Nov 18, 2010 1:38 pm
by aluchko
I've tried from neuron import gui, hoc, h, help, and test, and all cause the problem, "import numby" however doesn't cause an issue so it's definitely something going on with the import neuron. Is there somewhere in the code I should look to get a better idea of what's being executed under the hood?

My changes aren't really 7.2 specific so I'll try backporting to 7.1 and see if I still have the problem.

Re: import neuron has side effects?

Posted: Thu Nov 18, 2010 2:08 pm
by hines
Why don't we take this to email. Send me <michael dot hines at yale.edu> all the code necessary to exhibit
the problem along with instructions about how to launch.