Python 3.6.3:多个&#34;异常被忽略:<generator object ...“=”“in =”“flask =”“app =”“

时间:2018-02-16 17:37:48

标签: python flask generator system-error

= “”

我正在运行一个烧瓶应用程序,大约5个月前将所有内容从Python 2.7升级到3.

大多数事情已经变得足够顺利了,除了这个一直在当地烦扰我的事情。我在OSX 10.12.6上安装了MacBook,并在virtualenv下安装了Python 3.6.3

当一个请求来自一个看似有多个静态请求的页面(主要是.css,.js和图像文件)时,我似乎能够在任何地方使用生成器的任何地方得到这个错误在我的代码中。

一些示例(请求是flask.request对象):

检查路径是否以&#39; / static&#39;开头的地方。 of&#39; / admin / static&#39; (我的代码),

any(request.path.startswith(k) for k in self._static_paths)

Exception ignored in: <generator object CustomPrincipal._is_static_route.<locals>.<genexpr> at 0x11450f3b8>
Traceback (most recent call last):
  File "/Developer/repos/git/betapilibs/lbbsports/flask_monkeypatches.py", line 22, in <genexpr>
    any(_checker(request.path, k) for k in self._static_paths)
SystemError: error return without exception set

如果限制了网址路径,请检查登录用户是否具有相应的权限/角色

return role in (role.name for role in self.roles) 

Exception ignored in: <generator object UserMixin.has_role.<locals>.<genexpr> at 0x1155a7e08>
Traceback (most recent call last):
  File "/Developer/virtualenvs/lbb3/lib/python3.6/site-packages/flask_security/core.py", line 386, in <genexpr>
SystemError: error return without exception set

自定义位代码,以确保他们的&#34; sub&#34;帐户ID有效,

(not any(ident == account_id for ident in account_ids))

Exception ignored in: <generator object CustomSession.get_set_accounts.<locals>.<genexpr> at 0x115ff4fc0>
Traceback (most recent call last):
  File "/Developer/customflask/flasklogin.py", line 168, in <genexpr>
SystemError: error return without exception set

现在,在系统中没有任何似乎,我只是得到这些错误消息,而不是一致,只有有时。如果我在报告发生这些错误的任何地方设置断点,他们就不会再出错了。

如果我做了类似的事情,在第一个示例中,将其分解为request.path.startswith('/static') or request.path.startswith('/admin/static'),我不再收到错误消息,并且一般来说,我在其他地方使用请求时从来没有遇到任何问题应用程序。

1 个答案:

答案 0 :(得分:1)

我本地开发设置中出错的一点是我通过flask应用程序服务所有/ static和/ admin / static,而不是通过web服务器提供服务(在我的情况下,{{1} })。因此,对于我正在尝试的一些网址,可能有10个请求基本上同时进入,Flask处于调试模式,并且调试器也连接(通过nginx)。

当我遇到麻烦以确保从那里获得所有'/ static'和'/ admin / static'时,而不是通过烧瓶,而烧瓶每个网址只收到1个请求,这个问题就消失了。< / p>

我不会将此标记为答案,因为仍存在潜在问题,但如果其他人遇到与我相同的问题,这可以解决我的问题。