Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support for Async Performers in Effect Library #86

Copy link
Copy link
@giuliohome

Description

@giuliohome
Issue body actions

Hello,

I’m currently implementing an async performer, starting from a synchronous version. In the synchronous setup, I have:

result = sync_perform(mock_dispatcher, main_sequence(logger))

This approach uses a pure logic sequence for managing effects in main_sequence, which can be found here.

For the async version, I have created a custom async_perform function to handle asynchronous performers, defined here.

Usage

In the async main, the call looks like this:

result = await async_perform(mock_dispatcher, main_sequence(logger))

Here’s an example of an async performer:

# ...
    async def mock_create_request_performer(dispatcher, intent):
        logger.debug(f"Mock: Creating request... {intent.payload} with token {token}")
        await asyncio.sleep(1)
# ...
    return TypeDispatcher({
        CreateRequest: mock_create_request_performer,
# ...

Look at my feat/async branch for the whole sample.

Would this be considered the recommended approach for handling async performers, or are there any improvements or best practices that you’d suggest?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.