Skip to content

Transform python_bridge to an "asynchronous procedural" workflow #78

Closed

Description

@felixchenier

Problem statement

The current implementation is full of race condition probability. A Godot module may be instantiated before or after the python bridge, and therefore it's _ready function may or may not initialize its python counterpart before starting processing answers.

For example, a biofeedback module may try to send a start command in _ready and then wait for answer in _process. But the start command may not be received by Python, since it may not event be activated yet.

Screenshots

Proposition

Use a more procedural method where each call to Python wait for a return value before doing another call. No more "start" or "once" mode: a Python command is executed only once on demand, returns its return value, and then we check for new command requests, and so on.

Doing this blindly is a bad idea since the aim of using Python is to let calculations happen in parallel of the game engine, to not slow down Godot and miss frames. Therefore, this has to be still asynchrononous. In Godot, we would do:

func _process(delta):
    # Do some stuff here
    result = await(python_bridge.send(command, args))
    # Interpret result
    # Do something with result

We would not poll using python_bridge(receive). Instead, python_bridge.send() would return a signal, and then would wait for a UDP answer and process+send it via the signal once it receives it.

Activity

  1. self-assigned this
    on Sep 1, 2026
  2. felixchenier commented on Sep 11, 2026

    @felixchenier
    ContributorAuthor

    Closed with #80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions