yandex_tracker_client icon indicating copy to clipboard operation
yandex_tracker_client copied to clipboard

asyncio support

Open Olegt0rr opened this issue 5 years ago • 2 comments

Blocking requests in 2019...? Welcome to the future :)

async with aiohttp.ClientSession() as session:
    async with session.get('http://httpbin.org/get') as resp:
        print(resp.status)
        print(await resp.text())

Olegt0rr avatar Nov 04 '19 09:11 Olegt0rr

Hello! Where are a huge amount of python 2 services which are using this library, as soon as they move to python 3 we will be able to move to async syntax.

For now you can use

loop = asyncio.get_event_loop()
loop.run_in_executor(executor, some_func)

Smosker avatar Nov 05 '19 09:11 Smosker

Thanks, but I have already use yatracker with blackjack and hookers :)

from yatracker import YaTracker

tracker = YaTracker(org_id=..., token=...)

async def foo():
    # create issue
    issue = await tracker.create_issue('New Issue', 'KEY')
    
    # get issue
    issue = await tracker.get_issue('KEY-1')
    
    # update issue (just pass kwargs)
    await tracker.edit_issue('KEY-1', description='Hello World')

    # get list with transitions
    transitions = await issue.get_transitions()

    # execute first transition in list
    transition = transitions[0]
    await transition.execute()

Olegt0rr avatar Nov 07 '19 20:11 Olegt0rr