Replies: 8 comments
-
This improvement would involve a two level approach. First, every (most? there are 518 of them) occurrence of |
Beta Was this translation helpful? Give feedback.
-
I should also mention that handleable exceptions that occur in the hoc world typically can only be handled when one enters |
Beta Was this translation helpful? Give feedback.
-
When I redirect stderr and stdout most of the errors are captured, but sometimes parts of them leak through. Any idea how the message
A similer one is obtained when you try Are they transmitted differently? |
Beta Was this translation helpful? Give feedback.
-
I don't know precisely why stdout/stdin are not the same in hoc and python if python changes them. |
Beta Was this translation helpful? Give feedback.
-
If called without arguments it writes to devnull, and by passing the import os, sys
from contextlib import contextmanager
@contextmanager
def _suppress_nrn(stream=None, close=False):
if stream is None:
stream = open(os.devnull, "w")
close = True
old_stdout = sys.stdout
old_stderr = sys.stderr
sys.stdout = stream
sys.stderr = stream
try:
yield
finally:
if close:
stream.close()
sys.stdout = old_stdout
sys.stderr = old_stderr
I'll try to check that soon. |
Beta Was this translation helpful? Give feedback.
-
If I change
and finally an error:
Is there something else I have to include? Edit: I copy pasted some includes from another #include <math.h>
#include <nrnpython_config.h>
#include "section.h"
#include "nrniv_mf.h"
#include "membfunc.h"
#include "parse.h"
#include "hocparse.h"
#include "membdef.h" So switching For the exceptions I think I'll need a hands on example, it seems to be more complex than replacing some occurences ;p |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Generally the |
Beta Was this translation helpful? Give feedback.
-
Currently NEURON frequently writes the exception message into
stderr
and throws the sameRuntimeError: hoc error
everywhere. It would be an added value if PyNEURON would handle this gracefully, using diverse Python exceptions instead with the error message encapsulated inside of it.This allows for better and easier exception handling and can contribute to stability in environments where asking for permission is worse than asking for forgiveness (parallel computing e.g.).
Beta Was this translation helpful? Give feedback.
All reactions