Skip to content
Discussion options

You must be logged in to vote

You can edit your code like this:
import time, asyncio
from primitives import Queue

class server_task:
def init(self):
self.bbb = 'test text'
self.q = Queue()

async def test(self, reader, writer):
    print(self.bbb, 'main')

    print('server start')
    data = await reader.read(100)
    print('data IN:', data.decode())
    await self.q.put(data.decode())  # Put received data into the queue
    a = str('i am batman, not a return-server').encode()
    writer.write(a)
    await writer.drain()

    writer.close()
    await writer.wait_closed()

async def run_server(self):
    server = await asyncio.start_server(self.test, '192.168.1.160', 18888)
    async with server:
        await server.s…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by moppi79
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants