Closed GoogleCodeExporter closed 9 years ago
Can you run the latest snapshot version (
http://code.google.com/p/pircbotx/wiki/DevVersion )? There is a regression in
1.7 where OutputThread never was killed so the JVM just sat there
Just to let you know, your fix (marking the thread as a dameon thread) has been
brought up before but simply won't work. This is because now the JVM will exit
either randomly or right after you connect because there are no threads keeping
it open (remember all Listener threads are marked as dameon as well).
Original comment by Lord.Qua...@gmail.com
on 30 Oct 2012 at 12:11
I know this 'fix' wont work in the normal case where the bot is run as a
standalone bot. (this is why it should ofcourse be optional and default off)
The problem i have is when i try to run the bot as a dependant process to a
(unreliable) non-daemon process. (and am unable to always call shutdown from
the non-deamon process)
Original comment by pvgodd...@gmail.com
on 30 Oct 2012 at 1:18
That's why I'm suggesting trying the latest dev version as the current release
version has a bug in these circumstances. It should solve your problem
Original comment by Lord.Qua...@gmail.com
on 30 Oct 2012 at 1:21
Hi,
I just tried i with the latest dev version but this doesnt solve the problem i
have.
The following is psuedocode simplification of my problem
main(String[] args) {
PircBot bot = new Bot();
bot.connect(..);
LoggerFactory.createLogger(new IrcLogger(bot));
Thread nonDeamon = new Thread(new Runnable() {
//code effectively out of my control
Logger logbot =LoggerFactory.getLogger('irc'); // no direct reference to the bot
while(true_for_some_time) {
//This is the core proc
String stuff = doStuff();
log.info(stuff); ---> this goes to IRC
}
});
nonDeamon.start();
}
Because the main thread terminates after starting the process i want to log to
IRC i cant shut down the logger in the main thread. (this would be too soon).
Shutting down the bot in the forked thread is also not an option because this
is largely out of my control.
In this case the PircBotx's in/outputThreads keep the JVM alive after my
runnable is done. Again this is not a problem if the bot is a standalone bot,
and i dont regard it as a Bug Per-se
What i'm looking for is the irc bot automatically shut it self down if there
are no other (nondaemon) thread alive in the VM. The shutdown hooks seems to
make this a clean process (cleaning up the connections)
Hopefully this clarifies my problem a bit better.
If this feature isnt added i can work around it so it fine with me if you
reject it.
Regards,
Pieter Goddijn.
}
Original comment by pvgodd...@gmail.com
on 30 Oct 2012 at 2:36
Hi i've been looking into the construction with the shutdownHook some more, and
i think in most cases this would ensure the behavior i would want (bot disposes
as it goes out of scope). I'm my case this doesnt happen because the the
logAppender hold a reference to the bot.
So i think this makes my problem too much of an edgecase to actually justify
adding this as a feature. I still need to workaround myself because the
lifecycle of our loggers are not managed well enough.
Thanks for the quick replies and the upgrade of PircBot to PircBotX though!
With all the private finals in the original i was unable to work around this.
The event system also look nice.
Regards,
Pieter Goddijn
Original comment by pvgodd...@gmail.com
on 30 Oct 2012 at 4:41
I still think that you are probably doing something wrong, but if you want you
can override createInputThread() and createOuputThread() in PircBotX and mark
the threads as dameon threads there. Just make sure you have another thread
always waiting.
I'm going to go ahead and mark this as Invalid, but please comment again if you
need more help
Original comment by Lord.Qua...@gmail.com
on 30 Oct 2012 at 4:49
np
Thanks for the feedback
Original comment by pvgodd...@gmail.com
on 30 Oct 2012 at 11:57
Original issue reported on code.google.com by
pvgodd...@gmail.com
on 30 Oct 2012 at 12:05Attachments: