gevent.spawn not working

195 views
Skip to first unread message

Syed Nawaz

unread,
Nov 23, 2017, 11:08:59 PM11/23/17
to gevent: coroutine-based Python network library
Hi ,
I am new to python and gevent 
I was trying to execute the below program but spawn module is not found, can some one help?

import gevent

def main():
coroutines = []
def rmq_init():
global connection, channel
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='15.184.8.165', port= 5672))
channel = connection.channel()
print ("Connected to RMQ.........!")
#channel.exchange_declare(exchange='AG_CPPM_AUTH', exchange_type='topic', durable= True)
result = channel.queue_declare(queue="test1", exclusive=False, durable=False, auto_delete=True)
cppm_queue = result.method.queue
channel.queue_bind(exchange='AG_CPPM_AUTH', queue=cppm_queue, routing_key="#")

def on_response(ch, method, props, body):
global channel, username, password, response
response = body
#log.info('on_response response %s', response)
username = response
password = response
print (username)
# except Exception as e:
#log.error("exception: %s", e)

channel.basic_consume(on_response, no_ack=True,
queue=cppm_queue)
try:
channel.start_consuming()
except KeyboardInterrupt:
channel.stop_consuming()
channel.queue_delete()
channel.close()
connection.close()
gevent.sleep(5)
def hello(a, b):
print ("here")
gevent.sleep(5)

gevent.spawn(rmq_init)
gevent.spawn(hello)
if __name__ == '__main__':
main()



C:\Python34\python.exe C:/Users/nawazsye/PycharmProjects/radserver/gevent.py
Traceback (most recent call last):
  File "C:/Users/nawazsye/PycharmProjects/radserver/gevent.py", line 60, in <module>
    main()
  File "C:/Users/nawazsye/PycharmProjects/radserver/gevent.py", line 57, in main
    gevent.spawn(rmq_init)
AttributeError: 'module' object has no attribute 'spawn'

Process finished with exit code 1

Dorian Hoxha

unread,
Nov 26, 2017, 10:31:01 AM11/26/17
to gevent: coroutine-based Python network library
rename the file from `gevent.py` to something else

Jason Madden

unread,
Nov 26, 2017, 10:32:37 AM11/26/17
to gev...@googlegroups.com
cf. https://github.com/gevent/gevent/issues/1042
> --
> You received this message because you are subscribed to the Google Groups "gevent: coroutine-based Python network library" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gevent+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages