Callback or event signalling from c to python

Hi there! Are there any examples you may share on the following scenarios?

  1. Calling a python function/sub from a C program?
  2. Sincronizing C and python by means of an “Event”

What I’m looking into is to reuse the http_server example from espressif and somehow “calling” python when we receive a valid request.


Hi @Alex1
Currently, it is therefore possible to call C functions from Python, but not (yet) Python functions from C.
Check this doc for more info on C language interface.
However, I think there is a workaround until this feature is implemented. (But not a clean approach :sweat:)
You can have a C function that checks for event, A python function that calls this C function and checks if a flag has been raised. and a python thread that uses this python function.

def _get_event():

def _event_loop():
        while True:
            evt_type = _get_event()
            if evt_type == 0: # EVENT
                #do Stuff
    except Exception as e:

def start():

Let me know if you are developing a commercial product, If so, this feature could be arranged with the Zerynth team.

Hi @karimhamdy1, sorry for the late reply.
Yes I’m developing a commercial product.

With regard to this thread I decide to go classic python only and work with the timeouts until Zerynth gives us callbacks for sockets, I just started a thread to handle all sockets comms and seem to work fine.

Thanks any way.

Best regards

1 Like