Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventlet 如何使用,求demo #2

Open
caimaoy opened this issue Jan 4, 2018 · 10 comments
Open

eventlet 如何使用,求demo #2

caimaoy opened this issue Jan 4, 2018 · 10 comments

Comments

@caimaoy
Copy link
Contributor

caimaoy commented Jan 4, 2018

eventlet 如何使用?

@filamoon
Copy link
Owner

filamoon commented Jan 4, 2018

比如用gunicorn启动flask,如果并发模式采用 eventlet,就可以用 eventlet 的long poll

@caimaoy
Copy link
Contributor Author

caimaoy commented Jan 4, 2018

我还在想如果我用 flask worker 的模式 会有很多线程的问题。

@filamoon
Copy link
Owner

filamoon commented Jan 4, 2018

我在 celery 的 eventlet 模式下,实证可用,没有 thread 模式下必须等待30s才能退出的问题

@sunguangran
Copy link

eventlet 异步无效,请问是什么问题,环境mac py2.7

@filamoon
Copy link
Owner

filamoon commented Apr 2, 2018

需要先 monkey patch。如果用的 gunicorn 或者 celery -P eventlet,它们自己会负责初始化,就什么都不用做。

@xdjiangyang
Copy link

@filamoon 直接利用pyapollo编写代码时 eventlet 异步确实无效,在 apollo_client.py 的 import eventlet 下面添加 eventlet.monkey_patch() 就可以让 eventlet 异步生效。可否修改一下源码?

@filamoon
Copy link
Owner

filamoon commented May 2, 2018

def start(self, use_eventlet=False, eventlet_monkey_patch=False) 增加了一个开关来控制是否调用 eventlet.monkey_patch()

@sunguangran
Copy link

sunguangran commented Jul 16, 2018

还行不会执行啊,只有调用t.wait() 方法才会触发执行,但wait会阻塞~

@sunguangran
Copy link

大家有执行成功的?

@luciferYu
Copy link

我想在django中使用apollo配置中心来实现一些限速策略的设置。
于是我在settings.py中加入了

client = ApolloClient(app_id='WSCenter', cluster='default', config_server_url='http://192.168.14.35:8080',timeout=61)
client.start()
SECRET_KEY = client.get_value('SECRET_KEY', 'l^h%b2l9i6o-+g$ottqyw=+czg8me$=*aegww&6l)f3y&qlbg#')
'DEFAULT_THROTTLE_RATES': {
        'anon': '100/day',
        'user': client.get_value('throttle_rates_user', '100/minute'),  # 测试用
    },

重启django是可以读到配置文件的,但实现不了在线更新,
然后我修改start代码传参
client.start(use_eventlet=True,eventlet_monkey_patch=True)
报如下错误:

 File "E:\WSC\WSC\settings.py", line 22, in <module>
    client.start(use_eventlet=True,eventlet_monkey_patch=True)
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\pyapollo\apollo_client.py", line 67, in start
    eventlet.monkey_patch()
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\eventlet\patcher.py", line 265, in monkey_patch
    _green_existing_locks()
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\eventlet\patcher.py", line 356, in _green_existing_locks
    if isinstance(obj, rlock_type):
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\django\utils\functional.py", line 215, in inner
    self._setup()
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\django\conf\__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "E:\venv\WSC-x03IkHfZ\lib\site-packages\django\conf\__init__.py", line 125, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Process finished with exit code 1

请问可能是哪里发生了问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants