Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irker
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iDB
irker
Commits
a6662582
Commit
a6662582
authored
Oct 4, 2012
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Deal with exceptions in a more civilized way.
parent
d9a57aad
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
irkerd
+83
-77
83 additions, 77 deletions
irkerd
with
83 additions
and
77 deletions
irkerd
+
83
−
77
View file @
a6662582
...
...
@@ -58,7 +58,7 @@ except ImportError:
CONNECTION_MAX
=
200
green_threads
=
False
import
sys
,
getopt
,
urlparse
,
time
,
random
import
sys
,
getopt
,
urlparse
,
time
,
random
,
exceptions
import
threading
,
Queue
,
SocketServer
import
irc.client
,
logging
try
:
...
...
@@ -110,7 +110,7 @@ class Connection:
self
.
port
=
port
self
.
nick_trial
=
None
self
.
connection
=
None
self
.
status
=
"
unseen
"
self
.
status
=
None
self
.
last_xmit
=
time
.
time
()
self
.
last_ping
=
time
.
time
()
self
.
channels_joined
=
[]
...
...
@@ -159,12 +159,14 @@ class Connection:
def
enqueue
(
self
,
channel
,
message
):
"
Enque a message for transmission.
"
if
self
.
thread
is
None
or
not
self
.
thread
.
is_alive
():
self
.
status
=
"
unseen
"
self
.
thread
=
threading
.
Thread
(
target
=
self
.
dequeue
)
self
.
thread
.
setDaemon
(
True
)
self
.
thread
.
start
()
self
.
queue
.
put
((
channel
,
message
))
def
dequeue
(
self
):
"
Try to ship pending messages from the queue.
"
try
:
while
True
:
# We want to be kind to the IRC servers and not hold unused
# sockets open forever, so they have a time-to-live. The
...
...
@@ -241,6 +243,10 @@ class Connection:
self
.
last_xmit
=
time
.
time
()
self
.
irker
.
debug
(
1
,
"
XMIT_TTL bump (%s transmission) at %s
"
%
(
self
.
servername
,
time
.
asctime
()))
self
.
queue
.
task_done
()
except
:
(
exc_type
,
exc_value
,
exc_traceback
)
=
sys
.
exc_info
()
self
.
logerr
(
"
exception %s in thread for %s
"
%
\
(
exc_type
,
self
.
servername
))
def
live
(
self
):
"
Should this connection not be scavenged?
"
return
self
.
status
!=
"
expired
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment