Example #1
0

asyncio.ensure_future(testMe())


loop = asyncio.get_event_loop()


async def closer(signal):
    print("CLOSER")
    await asyncio.gather(c1.close(), c2.close())
    print("STOP")
    loop.stop()


loop.add_signal_handler(
    signal.SIGINT, lambda x=signal.SIGINT: asyncio.ensure_future(closer(x))
)
loop.set_debug(True)
try:
    loop.run_forever()
finally:
    m.close()
    s.close()
    cam.close()
    d.close()
    print("DONE")
    with suppress(asyncio.CancelledError, SubscriptionClosed):
        loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))
    loop.close()
Example #2
0
c.subscribe(d)
loop = asyncio.get_event_loop()
"""
def shutdown(signame):
    print("got signal %s: exit" % signame)
    loop = asyncio.get_event_loop()
    loop.stop()



for sig in (signal.SIGINT, signal.SIGTERM):
    loop.add_signal_handler(sig, shutdown, sig)

print("Event loop running forever, press Ctrl+C to interrupt.")
print("pid %s: send SIGINT or SIGTERM to exit." % os.getpid())
"""
try:
    loop.run_forever()
finally:
    print("CLOSING")

    m.close()
    s.close()
    c.close()
    d.close()

    with suppress(asyncio.CancelledError):
        loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))

    loop.close()
Example #3
0
import asyncio
from rtcbot import CVCamera, CVDisplay

camera = CVCamera()
display = CVDisplay()

display.putSubscription(camera)

try:
    asyncio.get_event_loop().run_forever()
finally:
    camera.close()
    display.close()
Example #4
0
import asyncio
from rtcbot import Websocket, RTCConnection, CVCamera

cam = CVCamera()
conn = RTCConnection()
conn.video.putSubscription(cam)

# Connect establishes a websocket connection to the server,
# and uses it to send and receive info to establish webRTC connection.
async def connect():
    # ws = Websocket("http://localhost:8080/ws")
    # ws = Websocket("https://rtcbot.dev/myRandomSequence1532")
    # ws = Websocket("http://13.127.250.133:8080/ws")
    # ws = Websocket("http://localhost:8080/xyz")  # xyz could be the remote device id, in multi_client mode.
    ws = Websocket("http://13.127.250.133:1452/xyz001")
    remoteDescription = await ws.get()
    robotDescription = await conn.getLocalDescription(remoteDescription)
    ws.put_nowait(robotDescription)
    print("Started WebRTC")
    await ws.close()

asyncio.ensure_future(connect())
try:
    asyncio.get_event_loop().run_forever()
finally:
    cam.close()
    conn.close()
Example #5
0
loop = asyncio.get_event_loop()

"""
def shutdown(signame):
    print("got signal %s: exit" % signame)
    loop = asyncio.get_event_loop()
    loop.stop()



for sig in (signal.SIGINT, signal.SIGTERM):
    loop.add_signal_handler(sig, shutdown, sig)

print("Event loop running forever, press Ctrl+C to interrupt.")
print("pid %s: send SIGINT or SIGTERM to exit." % os.getpid())
"""
try:
    loop.run_forever()
finally:
    print("CLOSING")

    m.close()
    s.close()
    c.close()
    d.close()

    with suppress(asyncio.CancelledError):
        loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))

    loop.close()
Example #6
0

@conn.subscribe
def onMessage(msg):  # Called when each message is sent
    global flag
    flag = not flag
    print("Got message:", msg, flag)


# Connect establishes a websocket connection to the server,
# and uses it to send and receive info to establish webRTC connection.
async def connect():
    ws = Websocket("https://82796db29997.ngrok.io/InventoTest12")
    remoteDescription = await ws.get()
    robotDescription = await conn.getLocalDescription(remoteDescription)
    ws.put_nowait(robotDescription)
    print("Started WebRTC")
    await ws.close()


asyncio.ensure_future(connect())
asyncio.ensure_future(receiver())
try:
    asyncio.get_event_loop().run_forever()
finally:
    display.close()
    speaker.close()
    mic.close()
    camera1.close()
    camera2.close()
    conn.close()