Damian's Dev Blog

Tor Development Reports

  • Contact
  • Stem
  • Tor

Status Report for July 2020

Posted by atagar on July 30, 2020
Posted in: Status Report.

Dear diary, pandemic day 7,114. Placed a fancy hat on the fish. Questioned sanity, but voices reassure me I’m still sane. Treasonous cucumber sentenced to food processor, but asparagus now conspires too? Pez dispenser is all I can trust.

Fish with hat


Asyncio

Vegetable coups aside, Illia and I migrated Stem to asyncio! Txtorcon was previously the only asynchronous game in town, but now Stem supports both synchronous and asynchronous usage.

import asyncio

from stem.control import Controller


async def print_version_async():
  async with Controller.from_port() as controller:
    await controller.authenticate()
    print('[with asyncio] tor is version %s' % await controller.get_version())


def print_version_sync():
  with Controller.from_port() as controller:
    controller.authenticate()
    print('[without asyncio] tor is version %s' % controller.get_version())

print_version_sync()
asyncio.run(print_version_async())
% python demo.py 
[without asyncio] tor is version 0.4.5.0-alpha-dev (git-9d922b8eaae54242)
[with asyncio] tor is version 0.4.5.0-alpha-dev (git-9d922b8eaae54242)

Internally Stem is now asynchronous from the bottom up. This provides deeper control over our execution, for example asyncio.wait_for() can apply a timeout to any of our methods.

Usually asyncio doesn’t play well with conventional usage, but Stem transparently applies a compatibility layer so synchronous users likely won’t even notice this change.

Posts navigation

← Status Report for May 2020
Status Report for October 2020 →
  • Recent Posts

    • Status Report for August 2022
    • Status Report for August 2021
    • Status Report for July 2021
    • Status Report for June 2021
    • Status Report for May 2021
  • Links

    • Contact
    • Stem
    • Tor
Proudly powered by WordPress Theme: Parament by Automattic.