Skip to content

Can't call rpc_request from event callbacks #3

@murilopolese

Description

@murilopolese

Can't get event loop from inside a coroutine, apparently. I have no idea how to fix this and it's probably because I should be doing this in a different way.

This code:

from communitysdk import list_connected_devices, MotionSensorKit
msk = None
devices = list_connected_devices()
if len(devices):
    if isinstance(devices[0], MotionSensorKit):
        msk = devices[0]
        def on_proximity(p):
            if p > 200:
                try:
                    msk.set_mode('proximity')
                except Exception as e:
                    print(e)
            else:
                print('proximity', p)
        def on_gesture(g):
            if g == 'up':
                try:
                    msk.set_mode('proximity')
                except Exception as e:
                    print(e)
            else:
                print('gesture', g)
        msk.on_proximity = on_proximity
        msk.on_gesture = on_gesture
else:
    print('there is no device connected')

Prints There is no current event loop in thread 'ThreadPoolExecutor-0_0'. when I swipe up on Motion Sensor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededpythonPython SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions