2015-01-02 5 views
1

내 앱용 동기식 JsonStorage를 사용하며 비동기식으로 전환하려고합니다.python kivy async storage

내 동기 호출했다 :

store.exists(store_index) 

내 작동하지 비동기 호출은 다음과 같습니다

store.exists(key=store_index,callback=callback_function) 
TypeError: exists() got an unexpected keyword argument 'callback' 

나는 또한 시도했다 :

def callback_function(store,key,result): 
    print "exists:",result 

store.exists(store_index, callback=callback_function) 

이 비동기 호출은 다음과 같은 예외가 발생 이 :

store.async_exists(store_index, callback=callback_function) 

그러나이 제기 : 내가 무슨 잘못을하고있는 중이 야

File "main.py", line 199, in __init__ store.async_exists(key=store_index,callback=colorButtonCallback) 
File "/home/mike/Dokumente/py-spielwiese/venv/local/lib/python2.7/sitepackages/kivy/storage/__init__.py", line 152, in async_existskey=key, callback=callback) 
TypeError: _schedule() got multiple values for keyword argument 'callback' 

? 당신은 세부 정보를 볼 async_exists을 읽을 수

store.async_exists(callback_function, store_index) 

:

답변

1

이것은 Kivy의 버그입니다. 마지막 시도는 거의 정확했다. @ Anzel의 코드는 똑같은 것을 작성하는 더 좋은 방법이지만 @ Anzel의 답안 코드와 동일하다. 그러나 결국에는 _schedule에서 오류가 발생합니다. 나는 이것을 kivy-dev에서 바로 고치기 위해 submitted a PR 만했습니다.

+0

알아두면 좋을 것 같습니다. – Anzel

1

async_exists는 키가 너무로 변경하려고 인자로 콜백을합니다.

희망이 도움이됩니다.