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