dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.2.4
djbkd has joined #cinch
ktulu has joined #cinch
<ktulu>
Hey quick quesiton hopefully. How does cinch do its threading? I'm doing some code using a MySQL database and I'm having some issues.
<dominikh>
ktulu: what kind of answer do you expect when asking "How?"
<dominikh>
each handler invocation goes in its own thread
<dominikh>
all handlers for the same plugin are in a thread group
<ktulu>
thats what I needed
<ktulu>
i'm running into 'connection in use' issues is all.
<dominikh>
ah.
<ktulu>
yeah
<ktulu>
I give ach of the 2 plugins that use a db their on connecitons of course...
<ktulu>
*own
* ktulu
sighs
<ktulu>
oddly. it only happens in the live channel not my dev channel
<dominikh>
I have no idea how popular Ruby ORMs/DB libs do their connection stuff nowadays, but the sensible option would be a global connection pool with an upper limit. ask for a connection and there's none available and it should block and wait until one is freed
<dominikh>
I'd hope that a sensible DB pool works like that
<ktulu>
its a wrapper for mysql2 that allows prepared statements
<ktulu>
so mysql2 basically
<ktulu>
perhaps if it uses a global pool then I should just create the connection in the main thread and pass the reference to the plugins.
<ktulu>
but the reason I didnt do that is I figured doing so would create the exact issue I have
<ktulu>
its weird since the other plugin runs fine, but the new one has issues when I wne t and had each fucntion create and close the connecitons as needed.
<dominikh>
sorry, I can't really say much about this. in the past I've only used libraries that handled this correctly under the hood (sequel, datamapper, just using the plain sqlite lib, etc)
<dominikh>
and I've been out of the loop for years now
<dominikh>
also, one has to differentiate between an actual connection to the database, and an abstract connection that really is a transparent pool of connections
<dominikh>
a single MySQL connection can only be used by a single query at a time, for example
<ktulu>
right
<ktulu>
mysql2 is supposed to be threadsafe too..dammit
<dominikh>
maybe you're doing it wrong ;)
<ktulu>
apparently so
<dominikh>
also, if you have a pool of connections, and say the limit is 1, and you're currently using a connection, iterating over a row pointer, and you try to kick off another query while still using that connection, you can't. that one connection is in use, you can't open a second one, and you will never release the first one as it's deadlocked. but again, that's assuming a particular pool implementation, and I have
<dominikh>
no idea how ruby libs do things
<ktulu>
see I even tried giving each function its own con
<ktulu>
open work close
<ktulu>
so somehow I think the first plugin's cons are affecting it
<ktulu>
k
<ktulu>
damn connection is weird
<ktulu>
fucking bar wifi
<dominikh>
don't people go to bars to drink, not to debug code? :P
<ktulu>
iI am drinking
<ktulu>
I just cant code and drink at work!
<dominikh>
drinking and coding doesn't seem to work out too well for you today ;)
<ktulu>
lord knows C/AL will drive a man to it
<dominikh>
so maybe work has figured it out
<ktulu>
hah
<ktulu>
im not even buzzed
<ktulu>
ah right
<ktulu>
may have fixed that
<ktulu>
other issue is in the live chan (wher eI load all plugins) the memo plugin does not even fire on its match
<dominikh>
does it work in… other channels?
<ktulu>
if its the only one loaded yes
<dominikh>
you're doing some weird things.
<ktulu>
eh would code help
<ktulu>
?
<dominikh>
more than vague proble descriptions? yes.