Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 15 15:33
    sethmlarson opened #271
  • Jan 14 23:39
    shamrin synchronize #13
  • Jan 14 23:39

    shamrin on listen

    format (compare)

  • Jan 14 20:21
    shamrin synchronize #13
  • Jan 14 20:21

    shamrin on listen

    clarify test_listener_cancel an… (compare)

  • Jan 14 17:22
    shamrin synchronize #13
  • Jan 14 17:22

    shamrin on listen

    Update test_triopg.py (compare)

  • Jan 13 07:14

    oremanj on master

    Add three random fixes noticed … Merge pull request #1866 from p… (compare)

  • Jan 13 07:14
    oremanj closed #1866
  • Jan 13 07:02
    pquentin opened #1866
  • Jan 13 06:57
    dependabot-preview[bot] synchronize #1824
  • Jan 13 06:57

    dependabot-preview[bot] on pip

    Bump pytest from 6.1.2 to 6.2.1… (compare)

  • Jan 13 06:57
    dependabot-preview[bot] synchronize #1856
  • Jan 13 06:57

    dependabot-preview[bot] on pip

    Bump sphinx from 3.3.1 to 3.4.3… (compare)

  • Jan 13 06:57
    dependabot-preview[bot] edited #1824
  • Jan 13 06:57
    dependabot-preview[bot] edited #1856
  • Jan 13 06:55
    dependabot-preview[bot] edited #1824
  • Jan 13 06:55
    dependabot-preview[bot] edited #1856
  • Jan 13 06:55

    dependabot-preview[bot] on pip

    (compare)

  • Jan 13 06:55

    dependabot-preview[bot] on master

    Bump pygments from 2.7.3 to 2.7… Merge pull request #1865 from p… (compare)

Peter Sutton
@dj-foxxy
It's just one thread sending stuff back to the event loop.
richardsheridan
@richardsheridan
OK i was worried about you piling up 20 threads waiting for trio to dequeue some events
still since run_sync_soon is non-blocking, your observer thread would spend more time waiting for events and less time waiting for trio this way, if that matters to you
Peter Sutton
@dj-foxxy
Does run_sync_soon keep everything in order? I need to process events in the order they're given to me by watchdog
richardsheridan
@richardsheridan
aha
that is a question i have too
for @njsmith or @oremanj maybe
I can receive events in order with a channel if they come in the main thread (in guest mode for example)
but if they come from another thread, what's the "right way" to get them into trio in order? the entry queue batches get flipped randomly
richardsheridan
@richardsheridan
@dj-foxxy your solution might be the first concise way to solve that particular problem that I've seen, as long as watchdog doesn't run out of buffer and start dropping events or something
Peter Sutton
@dj-foxxy
@richardsheridan glad to be of service :)
richardsheridan
@richardsheridan
haha
mostly i've just allowed out of order events in my use cases so far, but it's been on my mind
Joshua Oreman
@oremanj
@richardsheridan @dj-foxxy yes, run_sync_soon callbacks execute in order
richardsheridan
@richardsheridan
:thumbsup:
Joshua Oreman
@oremanj

from the docs:
“””
All calls with idempotent=False are processed in strict first-in first-out order.

If idempotent=True, then sync_fn and args must be hashable, and Trio will make a best-effort attempt to discard any call submission which is equal to an already-pending call. Trio will process these in first-in first-out order.

Any ordering guarantees apply separately to idempotent=False and idempotent=True calls; there’s no rule for how calls in the different categories are ordered with respect to each other.
“””

András Mózes
@mozesa
Hello! I have seen @richardsheridan's trio_guest_win32.py implementions and it is making me thinking. I am after a reliable OPC UA clients and hopefully I have found one QuickOPC, which provides COM objects. This is something new to me, some advice which path should I follow? i.e. pushing the COM objects access into a trio working thread or using trio guest mode? Thanks for your help in advance.
richardsheridan
@richardsheridan
@mozesa at first glance I don't see anything that makes guest mode possible. However, they do claim to support some asynchronous callback-based interfaces which may be more efficient to wrap compared to using worker threads
AmericanY
@AmericanY
if i do have two function. first function is to login to site. then the second will crawl the site.
so in this case, the right solution is to use nursery.start for the login function instead of nursery.start_soon ?
AmericanY
@AmericanY
what is the difference between nursery.start(func) and the normal await func()
i think that both of them is doing same operation
Kyle Altendorf
@altendky
@AmericanY await af() waits for af() to finish. await nursery.start(af) waits for af() to start.
@AmericanY where the latter requires that af() take a parameter so it can state when it has started, including feeding a value out at that point.
AmericanY
@AmericanY
@altendky Yes. I've been viewing this url already. Thank you. you made it simple for me to understand it now.
Kyle Altendorf
@altendky
@AmericanY good deal. sometimes you need more words, sometimes you need less to understand. :]
AmericanY
@AmericanY
@altendky is it :P https://i.imgur.com/FfUCLLj.png from python room :P
Kyle Altendorf
@altendky
@AmericanY i was guessing it was you :]
AmericanY
@AmericanY
@altendky :D yes. i should thank you more that you helped me a lot with trio. it's actually a very wonderful library and helped me a lot with async program instead of concurrent.future :P even trio creators is actually too helpful as well.
Kyle Altendorf
@altendky
yep, they've got a quality library and friendly help. could also be a friendly library and quality help, i guess...
András Mózes
@mozesa
@richardsheridan Thanks! Do you think I can leverage the async functions using pywin32.client or 🤔 (should) using Cython to be able to use QuickOPC`s own C/C++ library, natively?
András Mózes
@mozesa
I have been wondering how an open source project is capable to work for a long time. I mean I use Python and its packages but I always feel some doubt that maybe tomorrow one of my favorite package developer stop continuing the project. I will try to convince my leader to buy a subscription for tidelift. Does it make sense? Could tidelift help to open source projects?
Kyle Altendorf
@altendky
the idea is nice anyways. https://tidelift.com/lifter/search/pypi/pip shows that there's not enough funding to be a significant amount of the development time though (at least i assume that pip is a widely used package with significant development effort by several people).
neither trio nor twisted are listed as having any available income yet. https://tidelift.com/lifter/search/pypi/trio
András Mózes
@mozesa
pff I tell you the truth I haven't searched for trio but sqlalchemy. I have seen that there is a project which tries to improve cpython speed up to 5(?) times in the consecutive years. I really hope that it will be a successfully story. What is really worrying me than whenever I donate to PSF I will remain on the list for months, actually after a year... 😥
richardsheridan
@richardsheridan
@mozesa I can't say for your own application but I know I would definitely try their python bindings first
Quentin Pradet
@pquentin
@altendky Tidelift works by analyzing dependencies of subscribers -- and nobody puts pip in their requirements file :)
Many Python libraries get income that way, though:
Quentin Pradet
@pquentin
The best course of action for python-trio would be GitHub Sponsors, it works well
@njsmith knows that he should set that up so hopefully it will happen at some point :)
András Mózes
@mozesa
@richardsheridan Which one should I start with? (Boost.Python, Cython, PyBind11, etc.)
provided it is C++ lib
Nathaniel J. Smith
@njsmith
@mozesa for binding a C++ lib, the main ones I see folks recommend are PyBind11 or maybe cppyy
(cppyy is a bit different from a normal binding lib: it actually includes a full LLVM and Clang as part of the runtime, so the install is heavier but you can do wacky stuff like type C++ into a the REPL and run it directly)
Joshua Oreman
@oremanj
I’ve had a good experience maintaining some pretty extensive bindings with pybind11 at $dayjob. It is definitely preferable to Boost.Python which we used in the past.
András Mózes
@mozesa
Thanks! I try to wrap my head around it. I am only a bit familiar with it because of object oriented PLC programming. So I can use the API of a C++ lib, but how should I use it. I mean call it from a different thread and callback the results? The quickopc C++ itself is not an async lib.
Kyle Altendorf
@altendky
in regular python, context managers are the preferred tool for making sure you clean up resources you acquire (i think...). so as i write things in trio, async context managers seem to be my go-to. but, nurseries provide similar functionality and functions like trio.serve_tcp() use nursery.start() instead. is there some guiding principle as to which to use when? both even allow you to feed out some value 'in the middle'...
Joshua Oreman
@oremanj
Async context managers are lighter-weight and don't necessarily introduce any additional concurrency
If you have a stack of multiple ACMs, they will be exited in the opposite of the order in which they were entered. If you have multiple tasks in the same nursery started with nursery.start(), the most common way to stop them is to cancel the enclosing scope, which tears them all down at the same time.
But I agree there's substantial overlap in the use cases
Kyle Altendorf
@altendky
part of my curiosity comes from what i've got so far with the trio support in pymodbus where i ended up with the server having a method that you can use with trio.serve_tcp() while the client grew a context managet method.
https://github.com/altendky/pymodbus/blob/4187d5fe54beac6e9ced4e13568184360c674468/test/test_server_trio.py and the context manager creates a nursery in which to process some stuff (maybe because of the protocol-class/callback structure of pymodbus, or maybe because i haven't learned how to avoid it yet) https://github.com/altendky/pymodbus/blob/4187d5fe54beac6e9ced4e13568184360c674468/pymodbus/client/asynchronous/trio/__init__.py#L160
Nathaniel J. Smith
@njsmith
@mozesa generally speaking, once you wrap a C++ lib to give it a Python API, you kind of ... treat it like any other Python API :-). In this case, it'll be a sync API, so if operations are quick you can just call them regularly, or if they're long-running/blocking, then you'll want to push them into a thread, maybe