Cypress  1.0
C++ Spiking Neural Network Simulation Framework
Public Member Functions | Static Public Member Functions | List of all members
cypress::PythonInstance Class Reference

#include <pynn.hpp>

Public Member Functions

 PythonInstance (PythonInstance const &)=delete
 
void operator= (PythonInstance const &)=delete
 

Static Public Member Functions

static PythonInstanceinstance ()
 

Detailed Description

The Python interpreter is not completely isolated: importing numpy in 2 consecutive runs will lead to a Segmentation fault (compare https://github.com/numpy/numpy/issues/3837). Thus, all simulations have to be executed in a single interpreter. This class makes sure that the python interpreter is started and is kept alive, as long as on instance of the object exists. When the last instance is destroyed, the interpreter will be safely shutdown before reaching the end of main, preventing a segfault at the end of the application.

Note: Sub-interpreters and also this approach in general are not thread-safe. Instead of parallelizing simulations, you should use several threads in e.g. NEST (call pynn.nest='{"threads": 8}'), or combine several networks into one.

Constructor & Destructor Documentation

cypress::PythonInstance::PythonInstance ( PythonInstance const &  )
delete

Member Function Documentation

static PythonInstance& cypress::PythonInstance::instance ( )
inlinestatic
void cypress::PythonInstance::operator= ( PythonInstance const &  )
delete

The documentation for this class was generated from the following file: