I am having a trouble calling the .send()
function of a socket, that was declared at the global level.
from nanomsg import Socket, PAIR, PUB
s2 = Socket(PAIR)
s2.connect('tcp://127.0.0.1:49234')
s2.send(b'connect')
def myfunc():
global s2
s2.send(b'Got here!')
myfunc()
print('closing socket')
s2.close()
In the above example the data sent in myfunc()
never gets to the receiving socket. I know the receiving socket works because the .send()
at the global level is received.
-- addendum --
Just wanted to add that my actual application is a flask-ask web service for a custom Alexa skill and I have verified that myfunc()
is getting called by activating the corresponding Alexa custom skill intent.