运行时错误:线程10中没有当前事件循环,没有异步错误,但是没有异步功能

时间:2019-09-30 07:00:01

标签: python-3.x aiortc

我正在为WebRTC服务器设置python客户端。我正在使用aiortc库运行我的python客户端。但我收到“线程10中没有当前事件循环”

为了使我的代码易于管理,我尝试不使用任何异步函数,这是为了使我的python代码的行为类似于我的js客户端。 从其他解决方案中,我已经看到人们运行事件循环。但这一切都在服务器端。

这是我的Python文件,其中包含我的RTC库 (出于可读性和相关性,一些代码已被排除) 我的客户端文件将调用最后两个函数

客户端文件

@sio.event
def ready():
    print("starting signalling")
    createRTCPeer()
    pythonCreateDataChannel()

pythonRTC文件

import argparse
import asyncio
import logging
import time

from aiortc import RTCIceCandidate, RTCPeerConnection, RTCSessionDescription
from aiortc.contrib.signaling import add_signaling_arguments, create_signaling

pc = None
hannel = None

def channel_log(channel,t, message):
    print("channel(%s) %s %s" % (channnel.label, t, message))

def createRTCPeer():
    print("starting RTC creation")
    global pc
    pc = RTCPeerConnection()
    print("created RTC Peer:",pc)
    return pc


def pythonCreateDataChannel():
    print("creating datachannel")
    global channel
    channel = pc.createDataChannel("chat")
    channel_log(channel, "-", "created by local party")


我希望这是当两者都被调用时,我创建了一个RTCPeerConnection对象和一个RTCDataChannel对象,然后可以将它们用于从我的js客户端发送和接收消息

0 个答案:

没有答案