cjw123ztt / stocktupoui

realtime subscribe the stock tupo info
0 stars 2 forks source link

pika client same to android app, and support Jupyter Notebook单步运行,不过稳定性可能差一些 #55

Closed cjw123ztt closed 4 years ago

cjw123ztt commented 4 years ago

https://github.com/pika/pika https://pika.readthedocs.io/en/stable/ https://www.jianshu.com/p/7147c0070224 pip install pika Python 2.7 and 3.4+ are supported. image

cjw123ztt commented 4 years ago

uri=amqp://covprbbm:9exUT3KY19XpOfngiwkFVj99KOmM1xV5@fish.rmq.cloudamqp.com/covprbbm clientid=

cjw123ztt commented 4 years ago

exchange = "amq.fanout" routing_key ="NA" MAIL_TAG = "mailTag" MAIL_SUBJECT = "mailSubject" MAIL_SENDER = "mailSender" MAIL_RECEIVER = "mailReceiver" def on_message_callback(ch,method,properties,body): print("on_message_callback") print(properties) print(body) logging.info(body)

if name == 'main': connection = pika.BlockingConnection(pika.URLParameters(uri)) # channel = connection.channel() channel.queue_declare(clientid,False,False,True) channel.queue_bind(clientid,exchange,routing_key)

basic_publish(exchange, routing_key, body, properties=None, mandatory=False)

#hdrs = {u'مفتاح': u' قيمة', u'键': u'值', u'キー': u'値'}
hdrs={}
hdrs[MAIL_TAG]     = "query lzBankuaiFuture"
hdrs[MAIL_SUBJECT] = "query lzBankuaiFuture"
hdrs[MAIL_SENDER]  = clientid
properties = pika.BasicProperties(
    app_id='example-publisher',
    content_type='application/json',
    headers=hdrs)
channel.basic_publish(exchange,routing_key,"python pc client hello",properties)
channel.basic_consume(clientid,on_message_callback)
channel.start_consuming()
channel.close()
connection.close()
cjw123ztt commented 4 years ago

https://www.cnpython.com/pypi/handout markdown转换成html,用浏览器xian

cjw123ztt commented 4 years ago

Task exception was never retrieved future: <Task finished coro=<WebSocketProtocol13.write_message..wrapper() done, defined at C:\ProgramData\Anaconda3\lib\site-packages\tornado\websocket.py:1102> exception=WebSocketClosedError()> Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\websocket.py", line 1104, in wrapper await fut tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\websocket.py", line 1106, in wrapper raise WebSocketClosedError() tornado.websocket.WebSocketClosedError

cjw123ztt commented 4 years ago

Jupyter Notebook environment anaconda3 error https://www.jianshu.com/p/7d8ce818a923 C:\ProgramData\Anaconda3\Lib\site-packages\nb_conda\envmanager.py return { "environments": [root_env] + [get_info(env) for env in info['envs'] if env != root_env['dir']] }

cjw123ztt commented 4 years ago

Ensuring well-behaved connection with heartbeat and blocked-connection timeouts https://github.com/pika/pika/blob/master/docs/examples/heartbeat_and_blocked_timeouts.rst

cjw123ztt commented 4 years ago

1.(base) C:\Users\dfc>jupyter notebook --generate-config Writing default config to: C:\Users\dfc.jupyter\jupyter_notebook_config.py(改了之后不工作的) https://www.cnblogs.com/dj1232090/p/10648678.html 2.将目标最后的%USERPROFILE%替换成目标路径才可以

cjw123ztt commented 4 years ago

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/