Python3 not adding 'self' to class function call

180 views Asked by At

I have this asyncio class in python 3.4:

class Type1:

    def __init__(s,websocket,path,flds,MyId):
        global TypeOnes
        s.ws=websocket
        s.pt=path
        s.iId=flds
        s.ID=MyId
        s.cnt=0
        TypeOnes[MyId]=s
        s.Q=asyncio.Queue


    @asyncio.coroutine
    def handlerIn(s,rxed):
        #yield from s.Q.put(rxed)  # gave error missing positional 'item'
        #yield from s.Q.put(item=rxed)   # gave error missing positional 'self'
        yield from s.Q.put(self=s.Q,item=rxed) # gave error TypeError: _consume_done_getters() missing 1 required positional argument: 'self'

When HandlerIn is called I do not seem to be able to call Q.put, see commented code for attempts and results.

It's as if the self is just not being inserted correctly

I am in a debugger and I have checked the contents of the variables:

(handlerIn)>>> s.Q
<class 'asyncio.queues.Queue'>

(handlerIn)>>> rxed
'Button'
1

There are 1 answers

0
Canh On BEST ANSWER

I think the problem is that you haven't created an instance of asyncio.Queue. It should be

s.Q=asyncio.Queue()