server.send() should be sync and return a Future - no nead for double await
This commit is contained in:
parent
899d4821f0
commit
730fef38f3
2 changed files with 9 additions and 9 deletions
|
@ -42,9 +42,9 @@ class IServer(Server):
|
||||||
params: ConnectionParams
|
params: ConnectionParams
|
||||||
desired_caps: Set[ICapability]
|
desired_caps: Set[ICapability]
|
||||||
|
|
||||||
async def send_raw(self, line: str, priority=SendPriority.DEFAULT):
|
def send_raw(self, line: str, priority=SendPriority.DEFAULT) -> Future:
|
||||||
pass
|
pass
|
||||||
async def send(self, line: Line, priority=SendPriority.DEFAULT):
|
def send(self, line: Line, priority=SendPriority.DEFAULT) -> Future:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def wait_for(self, response: IMatchResponse) -> Awaitable[Line]:
|
def wait_for(self, response: IMatchResponse) -> Awaitable[Line]:
|
||||||
|
|
|
@ -37,12 +37,12 @@ class Server(IServer):
|
||||||
|
|
||||||
self._read_queue: Deque[Tuple[Line, List[Emit]]] = deque()
|
self._read_queue: Deque[Tuple[Line, List[Emit]]] = deque()
|
||||||
|
|
||||||
async def send_raw(self, line: str, priority=SendPriority.DEFAULT
|
def send_raw(self, line: str, priority=SendPriority.DEFAULT
|
||||||
) -> Future:
|
) -> Future:
|
||||||
return await self.send(tokenise(line), priority)
|
return self.send(tokenise(line), priority)
|
||||||
async def send(self, line: Line, priority=SendPriority.DEFAULT) -> Future:
|
def send(self, line: Line, priority=SendPriority.DEFAULT) -> Future:
|
||||||
prio_line = SentLine(priority, line)
|
prio_line = SentLine(priority, line)
|
||||||
await self._write_queue.put(prio_line)
|
self._write_queue.put_nowait(prio_line)
|
||||||
return prio_line.future
|
return prio_line.future
|
||||||
|
|
||||||
def set_throttle(self, rate: int, time: float):
|
def set_throttle(self, rate: int, time: float):
|
||||||
|
@ -71,9 +71,9 @@ class Server(IServer):
|
||||||
username = self.params.username or nickname
|
username = self.params.username or nickname
|
||||||
realname = self.params.realname or nickname
|
realname = self.params.realname or nickname
|
||||||
|
|
||||||
await self.send(build("CAP", ["LS", "302"]))
|
self.send(build("CAP", ["LS", "302"]))
|
||||||
await self.send(build("NICK", [nickname]))
|
self.send(build("NICK", [nickname]))
|
||||||
await self.send(build("USER", [username, "0", "*", realname]))
|
self.send(build("USER", [username, "0", "*", realname]))
|
||||||
|
|
||||||
async def _on_read_emit(self, line: Line, emit: Emit):
|
async def _on_read_emit(self, line: Line, emit: Emit):
|
||||||
if emit.command == "001":
|
if emit.command == "001":
|
||||||
|
|
Loading…
Reference in a new issue