A way to run an infinite loop without the stackoverflowexception on ironpython?

安稳与你 提交于 2019-12-13 18:46:04

问题


I'm having a little problem when trying to run an infinite loop in ironpython 2.7

Here is my script:

import urllib
import urllib2
import json

a=0
info = ''

def getInfo():
    url = 'https://api.bitfinex.com/v1/pubticker/btcusd'
    values = {}
    data = urllib.urlencode(values)
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)
    the_page = response.read()
    page_info = json.loads(the_page)
    return(page_info)

while 1:
    try:
        info = getInfo()
        a=a+1
        print("--"+str(a)+"--")
        if info != '':
            print(str(info['ask']))
    except Exception,e:
        print("--"+str(a)+"--")
        print(str(e))

When I run the debug inside the Visual Studio 2015 the script run beautifully, but when I try to run the script directly on ironpython 2.7 I get this:

So there is a workaround? I tried to use threads but I can't control the threads freely in ironpython for some unknown reason for me.

来源:https://stackoverflow.com/questions/35075110/a-way-to-run-an-infinite-loop-without-the-stackoverflowexception-on-ironpython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!