Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Tracepoints. #533

Closed
wants to merge 1 commit into from
Closed

Conversation

ssanderson
Copy link

@ssanderson ssanderson commented May 15, 2018

This is a tentative port of some tracepoint based tools I've used in gevent to trio. I'm not sure if this is actually something you're interested in, or if there's a more useful powerful version of this that could be implemented using more of trio's internals.

At any rate, I was curious to see what an async port would look like, so I figured it can't hurt to hack out a prototype to see what people think.

@ssanderson
Copy link
Author

Example script that shows how you might use this:

from trio import run, open_nursery, Event, sleep
from trio.trace import pausing, trace


e = Event()


async def foo():
    await trace("start of foo")
    print("in foo")


@run
async def main():
    print("starting")
    async with open_nursery() as n:

        n.start_soon(foo)

        async with pausing('start of foo'):
            print("in pausing block")

            await sleep(1)

            print("finishing pausing block")

        print("end of pausing block")
        await sleep(1)

@auvipy
Copy link

auvipy commented Oct 9, 2018

@njsmith what do you think about this?

@njsmith
Copy link
Member

njsmith commented Nov 1, 2018

@auvipy It's a neat idea! For context, I should mention @ssanderson and I were talking about it some at PyCon, so he opened the PR to demonstrate. I guess though that it isn't an obvious fit for the Trio core library (as opposed to living inside your code, or in a utility library, etc.), and it isn't obviously The One True Way That Everyone Should Use, so I don't think we're going to merge it here. But you should totally use it if you find it useful, and let us know how it goes :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants