Skip to content

Commit e4f205c

Browse files
committed
Moved the main loop of the unthreaded core lib (see commit description)
Moved the main loop to a separate function with an unambiguous name that is callable from Python modules. Previously, a Python LF program was calling the function main() directly. This was problematic because other imported Python modules (if they are also C extensions) could also have a main function.
1 parent 4f265bf commit e4f205c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

org.lflang/src/lib/Python/pythontarget.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static PyObject* py_get_elapsed_physical_time(PyObject *self, PyObject *args) {
217217
/**
218218
* Prototype for the main function.
219219
*/
220-
int main(int argc, char *argv[]);
220+
int lf_reactor_c_main(int argc, char *argv[]);
221221

222222
/**
223223
* Prototype for request_stop().
@@ -240,7 +240,9 @@ static PyObject* py_request_stop(PyObject *self) {
240240
//////////////////////////////////////////////////////////////
241241
///////////// Main function callable from Python code
242242
static PyObject* py_main(PyObject *self, PyObject *args) {
243-
main(1, NULL);
243+
DEBUG_PRINT("Initializing main.");
244+
const char *argv[] = {TOSTRING(MODULE_NAME), NULL };
245+
lf_reactor_c_main(1, argv);
244246

245247
Py_INCREF(Py_None);
246248
return Py_None;

0 commit comments

Comments
 (0)