Skip to content

Commit bd2f181

Browse files
committed
Don't catch exceptions when handling events & spikes
1 parent 98d9a3a commit bd2f181

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Modules/template/processor_template.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def handle_spike(self, source_node, electrode_name, num_channels, num_samples, s
6262
sorted_id (int): the sorted ID for this spike
6363
spike_data (numpy array): N x M numpy array, where N = num_channels & M = num_samples (read-only).
6464
"""
65-
# print("SPIKE RECEIVED! Source Node:", source_node, ", Electrode name:", electrode_name, ", Num channels:", num_channels, ", Sample num:", sample_number, ", Sorted ID:", sorted_id)
6665
pass
6766

6867
def start_recording(self, recording_dir):

Source/PythonProcessor.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ PythonProcessor::~PythonProcessor()
5757
if(Py_IsInitialized() > 0)
5858
{
5959
{
60+
delete pyModule;
61+
delete pyObject;
6062
py::gil_scoped_release release;
6163
}
6264
py::finalize_interpreter();
@@ -189,12 +191,10 @@ void PythonProcessor::handleTTLEvent(TTLEventPtr event)
189191
// Give to python
190192
// py::gil_scoped_acquire acquire;
191193

192-
try {
194+
if(py::hasattr(*pyObject, "handle_ttl_event"))
195+
{
193196
pyObject->attr("handle_ttl_event")(sourceNodeId, channelName.toRawUTF8(), sampleNumber, line, state);
194197
}
195-
catch (py::error_already_set& e) {
196-
handlePythonException("Python Exception!", "Error when handling ttl event in Python:", e);
197-
}
198198
}
199199
}
200200

@@ -224,13 +224,8 @@ void PythonProcessor::handleSpike(SpikePtr spike)
224224
// py::gil_scoped_acquire acquire;
225225
if(py::hasattr(*pyObject, "handle_spike"))
226226
{
227-
try {
228-
pyObject->attr("handle_spike")
229-
(sourceNodeId, electrodeName.toRawUTF8(), numChans, numSamples, sampleNum, sortedId, spikeData);
230-
}
231-
catch (py::error_already_set& e) {
232-
handlePythonException("Python Exception!", "Error when handling spike in Python:", e);
233-
}
227+
pyObject->attr("handle_spike")
228+
(sourceNodeId, electrodeName.toRawUTF8(), numChans, numSamples, sampleNum, sortedId, spikeData);
234229
}
235230
}
236231
}

0 commit comments

Comments
 (0)