Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 07:56

    dependabot-preview[bot] on pip

    (compare)

  • 07:56
    dependabot-preview[bot] closed #60
  • 07:56
    dependabot-preview[bot] labeled #77
  • 07:56
    dependabot-preview[bot] opened #77
  • 07:56

    dependabot-preview[bot] on pip

    Bump gidgethub from 3.1.0 to 3.… (compare)

  • 07:56

    dependabot-preview[bot] on pip

    (compare)

  • 07:56
    dependabot-preview[bot] closed #64
  • 07:55
    dependabot-preview[bot] labeled #76
  • 07:55
    dependabot-preview[bot] opened #76
  • 07:55

    dependabot-preview[bot] on pip

    Bump six from 1.12.0 to 1.14.0 … (compare)

  • 07:53

    dependabot-preview[bot] on pip

    (compare)

  • 07:53
    dependabot-preview[bot] closed #72
  • 07:53
    dependabot-preview[bot] labeled #75
  • 07:53
    dependabot-preview[bot] opened #75
  • 07:53

    dependabot-preview[bot] on pip

    Bump pytest from 5.2.1 to 5.3.3… (compare)

  • 06:45
    pquentin synchronize #191
  • 06:28
    dependabot-preview[bot] synchronize #1306
  • 06:28

    dependabot-preview[bot] on pip

    Bump pylint from 2.4.2 to 2.4.4… (compare)

  • 06:28
    dependabot-preview[bot] edited #1306
  • 06:27
    dependabot-preview[bot] edited #1306
Matthias Urlichs
@smurfix
@njsmith The list misses two backticks.
Nathaniel J. Smith
@njsmith
@smurfix fixed, thanks
Dave Hirschfeld
@dhirschfeld
Maybe Channel[T] is fine and Stream just needs to be renamed to ByteStream to prevent any confusion. It breaks the naming symmetry you have in the post but that does highlight that they're different things so ¯\(ツ)/¯?
dhirschfeld @dhirschfeld returns to lurking...
Peter Sutton
@dj-foxxy

I'm using trio.Path.read_text(), code worked until I started using a nursery. Now I get,

  File "/usr/lib/python3.7/site-packages/trio/_core/_traps.py", line 43, in cancel_shielded_checkpoint
    return (await _async_yield(CancelShieldedCheckpoint)).unwrap()
AttributeError: 'NoneType' object has no attribute 'unwrap'

Does this look like a common error? Do I need to post more code?

oakkitten
@oakkitten
if there's a Stream[bytes] and ByteStream, that's even more confusing
oakkitten
@oakkitten
one day someone will want to subclass Stream[bytes] that makes bytes uppercase and they will name it UppercasingByteStream
Laura F. D.
@Fuyukai
I mean the stdlib isn't any better
List[bytes] and bytearray comes to mind
Peter Sutton
@dj-foxxy
the process async context manager tries to kill on cancellation. This fails 'Operation not permitted' if the subprocess is sudo. How can I customize the behaviour?
Tim Stumbaugh
@tjstum_gitlab
Huh, I always thought that sudo relays signals to its child
Peter Sutton
@dj-foxxy
@tjstum_gitlab I'm not sure of the details but this example highlights the issue:
import trio

async def main():
    with trio.move_on_after(1):
        await trio.run_process(['sleep', '2'])
    print('Cancelled 1')

    with trio.move_on_after(1):
        await trio.run_process(['sudo', 'sleep', '2'])
    print('Cancelled 2')

trio.run(main)
Alex Boag-Munroe
@Ninpo
Isn't there a switch that helps that so subprocesses can be killed by the adult
preexec_fn=os.setpgrp I needed this so that my child processes could be killed by parent
Peter Sutton
@dj-foxxy
@Ninpo just passing preexec_fn=os.setpgrp doesn't seem to solve the problem.
Alex Boag-Munroe
@Ninpo
After the list not part of it right
trio.run_process(['sudo', 'sleep', '2'], preexec_fn=os.setpgrp)
Peter Sutton
@dj-foxxy
@Ninpo this is what I've got:
import os

import trio


async def main():
    with trio.move_on_after(1):
        await trio.run_process(['sleep', '2'])
    print('Cancelled 1')

    with trio.move_on_after(1):
        await trio.run_process(['sudo', 'sleep', '2'], preexec_fn=os.setpgrp)
    print('Cancelled 2')

trio.run(main)
Alex Boag-Munroe
@Ninpo
hrm. That's definitely usually the way to solve this problem :/
Peter Sutton
@dj-foxxy
@Ninpo, yep I use that solution with plain subprocess but it doesn't seem to be working here for me.
Alex Boag-Munroe
@Ninpo
Might be worth seeing how move_on_after is trying to kill it
Peter Sutton
@dj-foxxy
Also, is there a way of limited the max number of subprocesses?
NoskLo
@nosklo_gitlab
Just use a CapacityLimiter
limit = trio.CapacityLimiter(5)
... then later ...
async with limit:
    await trio.run_process(....)
Peter Sutton
@dj-foxxy
@nosklo_gitlab Exactly what I need!
Alex Boag-Munroe
@Ninpo
Is that new? I normally use Semaphore
NoskLo
@nosklo_gitlab
@Ninpo it is like a Semaphore but more specific to this use case; Also it has some additional error checking built-in
Alex Boag-Munroe
@Ninpo
Just finished reading the docs on it, nice
and probably what I'll use where I'd used Semaphore before :)
saves me passing it around so I can acquire and release in the right place
Tim Stumbaugh
@tjstum_gitlab

Calling socket.is_readable() on a closed socket raises a ValueError:

trio/_socket.py in is_readable(self)
    485             return bool(rready)
    486         p = select.poll()
--> 487         p.register(self._sock, select.POLLIN)
    488         return bool(p.poll(0))
    489

ValueError: file descriptor cannot be a negative integer (-1)

i can put together a patch to change that to a trio.ClosedResourceError if that's the desired approach there

Peter Sutton
@dj-foxxy
I've just "finished" my first project using trio: a simple MAC scanner. If anyone has got a seconds, I'd like some feedback (am I using trio correctly). https://git.fds.im/snippets/4
Nathaniel J. Smith
@njsmith
@dj-foxxy that NoneType error in traps.py is super weird looking. Did you figure it out?
@dj-foxxy and that's a good question about how trio should handle the case where it fails to kill the child process... Can you open an issue to discuss more fully?
@tjstum_gitlab ValueError does seem like the wrong thing there, especially because it's probably inconsistent between different platforms...
I guess the other option for an exception would be OSError(EBADFD) or however you spell that. But ClosedResourceError probably makes more sense, because there isn't actually any syscall returning EBADFD
Nathaniel J. Smith
@njsmith
@dj-foxxy I did a quick read of the code and didn't really see anything to comment on, it seemed pretty reasonable :-)
(I didn't try to validate the Condition usage)
Tim Stumbaugh
@tjstum_gitlab
hrm? os.read(-1, 4096) certainly seems to fail with BADFD. or do you mean "it's never something that isn't just a programming error"
Nathaniel J. Smith
@njsmith
@tjstum_gitlab I mean that when you call is_readable and it fails, the failure doesn't involve a syscall returning EBADFD
Peter Sutton
@dj-foxxy
@njsmith I didn't get the NoneType issues solve. I changed what I was doing and it didn't crop up again. I'll open an issue for the proc kill thing. As for my use of conditions: I'm really unsure how to use condition in async code. In threaded coded, I'd lock over shared data, but in async if you don't have to await while touching shared data, do you need to hold the condition (or the underlying lock?).
Nathaniel J. Smith
@njsmith
@dj-foxxy ah, gotcha. Well, if the NoneType thing happens again please let us know with more details, because that's definitely not supposed to happen :-)
And thanks for opening an issue for the process kill thing
Re: Conditions: they're pretty tricky to use! You're right that you don't necessarily need to lock your data to prevent race conditions, because so many operations in async code are automatically atomic. (Though you still might want to use locking just to be explicit and avoid having to think too hard about which operations are atomic and which ones aren't.)
Nathaniel J. Smith
@njsmith
But there's an additional wrinkle for Conditions, which is that you have to be careful not to miss notifications – if you're not in cond.wait when someone calls notify, then you'll never know that it happened. And the lock can sometimes help with this, because taking the lock also blocks anyone else from calling notify.
jtrakk
@jtrakk
What is BlockingIOError: [Errno 11] write could not complete without blocking?
from print(x)
Nathaniel J. Smith
@njsmith
@jtrakk from print that means you put your stdout in non-blocking mode, and print isn't prepared for that
Are you using FdStream to talk to stdout?