- 歩哨:8.4.0
- 歩哨-youtrackプラグイン:0.3.1
- youtrack- 6.5.17105
- のpython-memcachedを:1.53
私はthisプラグインを使用してsentryにyoutrackを統合しようとしています。歩哨-youtrackプラグイン:PicklingErrorは:<型 'ジェネレータ'>酸洗いすることはできません:__発電__builtin属性の検索に失敗した
[その他] - > [YouTrackの作成]をクリックすると、ページがハングしているようです。 syslogのを見て、私はこれを見た:
Traceback (most recent call last):
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/utils/decorators.py", line 29, in _wrapper
return bound_func(*args, **kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/utils/decorators.py", line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/utils/decorators.py", line 25, in bound_func
return func(self, *args2, **kwargs2)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/web/frontend/base.py", line 172, in dispatch
return self.handle(request, *args, **kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/web/frontend/group_plugin_action.py", line 25, in handle
response = plugin.get_view_response(request, group)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/plugin.py", line 113, in get_view_response
return super(YouTrackPlugin, self).get_view_response(request, group)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/plugins/base/v1.py", line 296, in get_view_response
response = self.view(request, group)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/plugin.py", line 131, in view
return view(request, group, **kwargs)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/plugins/bases/issue.py", line 169, in view
form = self.get_new_issue_form(request, group, event)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/plugin.py", line 77, in get_new_issue_form
project_fields=self.get_project_fields(group.project),
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/plugin.py", line 57, in get_project_fields
return cached_fields(self.get_option('ignore_fields', project))
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/utils.py", line 16, in wrapper
cache.set(key, result, timeout)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/core/cache/backends/memcached.py", line 82, in set
self._cache.set(key, value, self._get_memcache_timeout(timeout))
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 740, in set
return self._set("set", key, val, time, min_compress_len, noreply)
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1060, in _set
return _unsafe_set()
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1034, in _unsafe_set
store_info = self._val_to_store_info(val, min_compress_len)
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 998, in _val_to_store_info
pickler.dump(val)
PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed
トレースバック(https://github.com/bogdal/sentry-youtrack/blob/master/sentry_youtrack/utils.py#L6を)フォロー:
def cache_this(timeout=60):
def decorator(func):
def wrapper(*args, **kwargs):
def get_cache_key(*args, **kwargs):
params = list(args) + kwargs.values()
return md5("".join(map(str, params))).hexdigest()
key = get_cache_key(func.__name__, *args, **kwargs)
result = cache.get(key)
if not result:
result = func(*args, **kwargs)
cache.set(key, result, timeout)
return result
return wrapper
return decorator
私はresult
が発電機であるため、私たちはこのエラーを得たことを理解しています。
https://github.com/bogdal/sentry-youtrack/blob/master/sentry_youtrack/plugin.py#L51:
def get_project_fields(self, project):
@cache_this(600)
def cached_fields(ignore_fields):
yt_client = self.get_youtrack_client(project)
return yt_client.get_project_fields(
self.get_option('project', project), ignore_fields)
return cached_fields(self.get_option('ignore_fields', project))
https://github.com/bogdal/sentry-youtrack/blob/master/sentry_youtrack/youtrack.py#L198:だから
def get_project_fields(self, project_id, ignore_fields=None):
ignore_fields = ignore_fields or []
for field in self.get_project_fields_list(project_id):
if not field['name'] in ignore_fields:
yield self._get_custom_project_field_details(field)
、私はリストに変換しようとしている:
if not result:
result = func(*args, **kwargs)
cache.set(key, [f for f in result], timeout)
return result
が、それでも同じエラーを得た:
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/utils.py", line 16, in wrapper
cache.set(key, [f for f in result], timeout)
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/core/cache/backends/memcached.py", line 82, in set
self._cache.set(key, value, self._get_memcache_timeout(timeout))
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 740, in set
return self._set("set", key, val, time, min_compress_len, noreply)
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1060, in _set
return _unsafe_set()
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1034, in _unsafe_set
store_info = self._val_to_store_info(val, min_compress_len)
File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 998, in _val_to_store_info
pickler.dump(val)
PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed
は、その後、私は、ファイルへval
の値をログに記録しようとした:
try:
pickler.dump(val)
except Exception:
with open('/tmp/quanta.log', 'a+') as f:
f.write(str(val))
が、そのファイルが作成されません。それでもエラーがCan't pickle <type 'generator'>...
は、それがされていた間、と言ったのはなぜ
- :だから
File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../sentry_youtrack/utils.py", line 16, in wrapper cache.set(key, [f for f in result], timeout) File "/usr/local/sentry/local/lib/python2.7/site-packages/sentry/../django/core/cache/backends/memcached.py", line 82, in set self._cache.set(key, value, self._get_memcache_timeout(timeout)) File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 740, in set return self._set("set", key, val, time, min_compress_len, noreply) File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1060, in _set msg = msg[1] File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 1034, in _unsafe_set File "/usr/local/sentry/local/lib/python2.7/site-packages/memcache.py", line 998, in _val_to_store_info try: PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed
、私は2つの質問を持っている:そして、奇妙なことは、エラーが前と同じラインで起こったことをトレースバック言われていますリストに変換?
- の値を知るためにこの状況をデバッグするには、
pickler.dump(val)
を呼び出しますか?
'(結果のfのための)'はジェネレータであり、リストではありません。あなたは '' fの結果のfのために '' – cuonglm
ああ、すみません。実際には私は2番目のスタックを使用しました。stacktraceを見てください: 'cache.set(key、[f in f in result]、timeout)'。編集されました。 – quanta