havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.0, 3.0.3, 2.7.5: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
John_Ivan has quit [Ping timeout: 240 seconds]
darkxploit has quit [Ping timeout: 240 seconds]
perrierjouet has joined #ruby
perrierjouet has quit [Quit: WeeChat 3.4]
Guest9014 has quit [Ping timeout: 240 seconds]
perrierjouet has joined #ruby
<nakilon> that moment when you realise you just wanted to use a single concurrent pattern but it's already two of them and you need the third one...
<nakilon> to obtain the data that isn't exposed in API I use chromium wrapped in semaphore(1) and now I'm thinking to use some pool of 5 browser instances
<nakilon> how do I implement it with stdlib? I'm thinking about 5 loops that are somehow readd themselves to Queue
<nakilon> or should they readd themselves to Enumerator?
perrierjouet has quit [Quit: WeeChat 3.4]
perrierjouet has joined #ruby
<nakilon> hm, the enumerator block does not know when the instance is free
Sheilong has quit []
perrierjouet has quit [Quit: WeeChat 3.4]
perrierjouet has joined #ruby
perrierjouet has quit [Remote host closed the connection]
perrierjouet has joined #ruby
<nakilon> with Queue I can now even get rid of Async::Semaphore; but now another weird thing happened: "Async::Task | ThreadError: Attempt to unlock a mutex which is not locked | Caused by Async::Stop: Async::Stop"
<nakilon> I feel like Timeout and Async aren't friends
<nakilon> maybe in ruby 3 I should use something different from Timeout::timeout.new?
<nakilon> where are the async gem normal docs?
<nakilon> though it's not clear what is this method https://www.rubydoc.info/gems/async/Async/Task#with_timeout-instance_method -- is it available if I add "do |subtask|"? I see aliases and some that object is some "parent" but it's not clear what class it is
<nakilon> weird to call "Scheduler" object a "subtask" but I've seen it in some example
<ox1eef> if it's IO i think you can use IO.select with a fourth arg as the duration of the timeout
<nakilon> so I've replaced Timeout::timeout.new with subtask.with_timeout and it threw the "ThreadError: Attempt to unlock a mutex which is not locked" even faster lol
<ox1eef> fun
<nakilon> or actually maybe that's actually ok and I had to have this exception always but it was supressed/delayed and that was probably a reason of unpleasant progress behaviour of the program I described earlier; I should think what to do with failed tasks
<nakilon> though the error message makes no sense to lib user who just faced a timeout
<nakilon> I even see in docs: message = "execution expired" -- but it's never to be found in the error printed
<ox1eef> still early days for async, if you find something to improve might be worth a GH issue
<nakilon> hm, I've reduced the timelimit to cause the error and saw "Async::TimeoutError: execution expired" printed so that error above was for some another unknown reason, it's not my timeout
ZAJDAN1 has quit [Ping timeout: 240 seconds]
<nakilon> found some another "hanging stdout" issue: https://github.com/socketry/async/issues/137
Thanzex7 has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
<nakilon> looks like when you define a task that immediately fails and you do .wait it quickly prints the exception but the return from .wait takes almost a second
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nakilon> or even to two seconds; I rescue the .wait to print the task.status (it is :failed) and reraise to stop the program (because it does not stop on its own if it's StandardError)
<nakilon> finally after this https://dpaste.org/ZLfW/slim it really fails now and prints the real reason; and before it hangs )
<nakilon> now I see not only "ThreadError: Attempt to unlock a mutex which is not locked" followed by "Caused by Async::Stop: Async::Stop" but also "some async task failed (Exception)", "Attempt to unlock a mutex which is not locked (ThreadError)", "execution expired (Async::TimeoutError)"
<nakilon> for some reason my (4th) error was not printed and it confused me; though it's weird that if I throw Timeout a bit earlier (like when I tested setting very low Timeout.new arg value) it was printed
e2 has quit [Quit: Stable ZNC provider #bnc4you]
<nakilon> ok, async docs don't open anymore; I need adam12 )
cdown has quit [Remote host closed the connection]
cdown has joined #ruby
<nakilon> subtask.with_timeout accepts the error message arg only in async -v 2.0.0 that is only for ruby 3.1 but in rbenv there is only 3.0.2 and 3.1.0-dev _<>
e2 has joined #ruby
fef has joined #ruby
jlindgren has quit [Remote host closed the connection]
jlindgren has joined #ruby
mooff has quit [Quit: Quit]
mooff has joined #ruby
<havenwood> nakilon: update ruby-build
<nakilon> havenwood Warning: ruby-build 20211019 already installed
nakilon has left #ruby [rasengan did nothing wrong]
nakilon has joined #ruby
<nakilon> oops, pressed something
<nakilon> the error chain is still changing time to time; now I see my timeout line in backtrace but not my error message -- instead it is "Attempt to unlock a mutex which is not locked", "attempt to resume the current fiber (FiberError)"
nullheroes2 has quit [Quit: WeeChat 2.3]
ur5us has quit [Ping timeout: 240 seconds]
constxd_ has quit [Ping timeout: 256 seconds]
bluedust has joined #ruby
fef has quit [Ping timeout: 276 seconds]
oxfuxxx has joined #ruby
<nakilon> google knows nothing about "attempt to resume the current fiber"; I would report it if I could localize it; the backtrace is short: https://dpaste.org/X02b/slim
bluedust_ has joined #ruby
bluedust has quit [Remote host closed the connection]
bluedust has joined #ruby
bluedust_ has quit [Ping timeout: 256 seconds]
<nakilon> changed Timeout::timeout to subtask.with_timeout and error is gone
<nakilon> (the 2 seconds large lag I said about earlier -- that's maybe because thousands of tasks starting together eat too much ram or disk read)
oxfuxxx has quit [Quit: can you please adjust your IRC quit message to be less transphobic?]
Duneyrr has joined #ruby
_ht has joined #ruby
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
bluedust has quit [Read error: Connection reset by peer]
bluedust has joined #ruby
ZAJDAN1 has joined #ruby
Duneyrr has quit [Ping timeout: 250 seconds]
infinityfye has joined #ruby
Guest9014 has joined #ruby
teclator has joined #ruby
Jonopoly has joined #ruby
ZAJDAN2 has joined #ruby
ZAJDAN1 has quit [Ping timeout: 240 seconds]
mdemo has quit [Quit: The Lounge - https://thelounge.github.io]
duderonomy has joined #ruby
gproto23 has joined #ruby
<nakilon> meh, the "attempt to resume the current fiber" is with me again, and happens just every several seconds _--
wnd-conn is now known as wnd
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
nmollerup has quit [Remote host closed the connection]
nmollerup has joined #ruby
Bounga has joined #ruby
gproto23 has quit [Remote host closed the connection]
random-jellyfish has joined #ruby
Duneyrr has joined #ruby
fef has joined #ruby
BSaboia has joined #ruby
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
fef has quit [Ping timeout: 276 seconds]
yassernasc has joined #ruby
random-jellyfish has quit [Ping timeout: 256 seconds]
John_Ivan_ has quit [Read error: Connection reset by peer]
John_Ivan has joined #ruby
constxd_ has joined #ruby
Jonopoly has quit [Quit: WeeChat 3.0]
taupiqueur has joined #ruby
taupiqueur has quit [Ping timeout: 240 seconds]
Duneyrr has quit [Ping timeout: 250 seconds]
taupiqueur has joined #ruby
fef has joined #ruby
Guest9014 has quit [Ping timeout: 240 seconds]
mayo has joined #ruby
<mayo> hi
<mayo> anyone here?
mayo has quit [Client Quit]
Guest9014 has joined #ruby
<yassernasc> hi mayo, how are you?
Guest9014 has quit [Ping timeout: 256 seconds]
constxd_ has quit [Ping timeout: 256 seconds]
gr33n7007h has quit [Quit: WeeChat 3.4]
Duneyrr has joined #ruby
gr33n7007h has joined #ruby
yassernasc has quit [Ping timeout: 256 seconds]
oxfuxxx has joined #ruby
yassernasc has joined #ruby
yassernasc has quit [Remote host closed the connection]
<adam12> morning
ZAJDAN2 has quit [Ping timeout: 256 seconds]
<oz> hello
<oz> hey, has anyone played with yjit in prod yet? :)
<adam12> oz: I haven't yet. And I can't try it in dev currently since I'm working from an M1
<adam12> I actually don't find Ruby slow, other than at startup when it walks $LOAD_PATH a billion times.
<oz> well, it's fast enough for a lot of folks, and I'm not complaining either, but I also like free performance improvements.
<adam12> Yeah, I'm just saying for my projects I haven't had a need yet, so it's not been top of my radar. I'm generally IO Bound.
<adam12> It will be nice to experiment with once it supports M1.
Duneyrr has quit [Ping timeout: 250 seconds]
gr33n7007h has quit [Ping timeout: 256 seconds]
gr33n7007h has joined #ruby
bluedust_ has joined #ruby
bluedust has quit [Ping timeout: 256 seconds]
oxfuxxx has quit [Quit: can you please adjust your IRC quit message to be less transphobic?]
ZAJDAN has joined #ruby
jlindgren has quit [Quit: ZNC 1.8.2 - https://znc.in]
jlindgren has joined #ruby
ZAJDAN1 has joined #ruby
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
ZAJDAN has quit [Ping timeout: 256 seconds]
roadie has joined #ruby
bluedust_ has quit [Remote host closed the connection]
taupiqueur_ has joined #ruby
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur_ has quit [Ping timeout: 240 seconds]
gproto23 has joined #ruby
fef has quit [Quit: Leaving]
Duneyrr has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
Duneyrr has quit [Client Quit]
Duneyrr has joined #ruby
taupiqueur has joined #ruby
Duneyrr has quit [Quit: Leaving]
Tomte has joined #ruby
fef has joined #ruby
taupiqueur_ has joined #ruby
taupiqueur has quit [Ping timeout: 256 seconds]
John_Ivan_ has joined #ruby
John_Ivan has quit [Ping timeout: 240 seconds]
gproto23 has quit [Quit: Leaving]
Sheilong has joined #ruby
Bounga has quit [Ping timeout: 240 seconds]
bluedust has joined #ruby
taupiqueur_ has quit [Ping timeout: 240 seconds]
Tomte has quit [Ping timeout: 250 seconds]
bluedust has quit [Remote host closed the connection]
ZAJDAN1 has quit [Ping timeout: 256 seconds]
goldfish has joined #ruby
Guest9014 has joined #ruby
taupiqueur has joined #ruby
taupiqueur has quit [Ping timeout: 256 seconds]
Rounin has quit [Ping timeout: 240 seconds]
cdown has quit [Remote host closed the connection]
cdown has joined #ruby
fef has quit [Quit: Leaving]
Tomte has joined #ruby
taupiqueur has joined #ruby
axsuul has quit [Ping timeout: 256 seconds]
taupiqueur has quit [Ping timeout: 256 seconds]
axsuul has joined #ruby
<Sheilong> How do I add multiple keys at once to a hash instance with the same default value for all keys?
<adam12> Sheilong: Something like hash["foo"] = hash["bar"] = hash["baz"] = "ohai" ?
<adam12> Sheilong: I'm not sure I'd do that, tbh, but if you're careful it might be OK. I'd probably try to #dup the value if possible.
<Sheilong> adam12: Yes, but the keys are all in a list.
<Sheilong> I wanted all keys to have a default value of zero, but somehow populate the hash passing the list with the keys
<adam12> keys.each_with_object(initial_hash) { |key, obj| obj[key] = 0 }
<adam12> Sheilong: You could always set a default for the entire Hash?
taupiqueur has joined #ruby
taupiqueur has quit [Ping timeout: 240 seconds]
<Sheilong> adam12: I thanks, that did the job
fredlinhares has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
bluedust has joined #ruby
goldfish has quit [Ping timeout: 268 seconds]
fredlinhares has quit [Read error: Connection reset by peer]
bluedust has quit [Ping timeout: 240 seconds]
fredlinhares has joined #ruby
taupiqueur has joined #ruby
roadie has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
fredlinhares has quit [Read error: Connection reset by peer]
Tomte has quit [Read error: Connection reset by peer]
fredlinhares has joined #ruby
Thanzex has quit [Read error: Connection reset by peer]
Thanzex has joined #ruby
ur5us has joined #ruby
roadie has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
yassernasc has joined #ruby
yassernasc has quit [Remote host closed the connection]
ZAJDAN1 has joined #ruby
roadie has joined #ruby
<adam12> Hmm. I'm kind of surprised that a match in a case/in is hoisted out of the case statement....
fredlinhares has quit [Read error: Connection reset by peer]
<adam12> I wonder if it's a dry-monads thing.
<adam12> case 1; in Integer => y; end; p y
roadie has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
fredlinhares has joined #ruby
roadie has quit [Remote host closed the connection]
<adam12> I feel like docs don't show that all.
___nick___ has quit [Ping timeout: 256 seconds]
_ht has quit [Remote host closed the connection]
fredlinhares has quit [Quit: WeeChat 3.4]
Vaevictus has joined #ruby
<Vaevictus> i've got an array of objects... i need to hashify them based on a specific attribute ... what should i be looking for?
<adam12> Hashify?
<Vaevictus> i need to be able to search the array for the object that matches the attribute
<adam12> [foo, bar, baz].find { |obj| obj.attribute == "the one" }
<Vaevictus> no
<adam12> Vaevictus: Show code.
<Vaevictus> i'll be doing this thousands of times
<Vaevictus> i need to iterate the array one time and use one of the object attributes as an index
<adam12> You want some sort of index then?
<Vaevictus> aye
<adam12> Are you concerned about duplicate keys?
<adam12> Simple solution: just build a Hash with the key being the attribute value, and the value being the object.
sagax has quit [Ping timeout: 240 seconds]
Sheilong has quit []
infinityfye has quit [Ping timeout: 240 seconds]
taupiqueur has quit [Ping timeout: 250 seconds]
<havenwood> Vaevictus: For example, if you have: [{aim: true}, {aim: false}, {aim: false}].to_h { [_1.fetch(:aim), _1] }
<havenwood> #=> {true=>{:aim=>true}, false=>{:aim=>false}}
<havenwood> Vaevictus: Does that duplicate key being squashed into one matter?
<havenwood> If there won't be duplicates or it's find for duplicates to point to the first object, a little #to_h and block is all it takes.
<havenwood> If there will be duplicates, you just have to decide what you want it to return. All matching objects? Just one?
BSaboia has quit [Quit: This computer has gone to sleep]
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
taupiqueur has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
taupiqueur has quit [Ping timeout: 256 seconds]
ZAJDAN1 has quit [Ping timeout: 240 seconds]