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
3e0020e4
Commit
3e0020e4
authored
Aug 26, 2012
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Channel timeout appears to work.
parent
68ede3c4
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
irker.py
+10
-6
10 additions, 6 deletions
irker.py
with
10 additions
and
6 deletions
irker.py
+
10
−
6
View file @
3e0020e4
...
@@ -20,7 +20,7 @@ TO-DO: Multiple irkers could try to use the same nick
...
@@ -20,7 +20,7 @@ TO-DO: Multiple irkers could try to use the same nick
HOST
=
"
localhost
"
HOST
=
"
localhost
"
PORT
=
4747
PORT
=
4747
TTL
=
30
# Connection time to live in seconds
TTL
=
(
3
*
60
*
60
)
# Connection time to live in seconds
# No user-serviceable parts below this line
# No user-serviceable parts below this line
...
@@ -34,7 +34,7 @@ class SessionException(exceptions.Exception):
...
@@ -34,7 +34,7 @@ class SessionException(exceptions.Exception):
class
Session
():
class
Session
():
"
IRC session and message queue processing.
"
"
IRC session and message queue processing.
"
count
=
1
count
=
0
def
__init__
(
self
,
irker
,
url
):
def
__init__
(
self
,
irker
,
url
):
self
.
irker
=
irker
self
.
irker
=
irker
self
.
url
=
url
self
.
url
=
url
...
@@ -59,7 +59,7 @@ class Session():
...
@@ -59,7 +59,7 @@ class Session():
def
dequeue
(
self
):
def
dequeue
(
self
):
"
Try to ship pending messages from the queue.
"
"
Try to ship pending messages from the queue.
"
while
True
:
while
True
:
# We want to b
y
kind to the servers and not hold unused
# We want to b
e
kind to the
IRC
servers and not hold unused
# sockets open forever, so they have a time-to-live. The
# sockets open forever, so they have a time-to-live. The
# loop is coded this particular way so that we can drop
# loop is coded this particular way so that we can drop
# the actual server connection when its time-to-live
# the actual server connection when its time-to-live
...
@@ -67,11 +67,13 @@ class Session():
...
@@ -67,11 +67,13 @@ class Session():
# queue fills up again.
# queue fills up again.
if
not
self
.
server
:
if
not
self
.
server
:
self
.
server
=
self
.
irker
.
irc
.
server
()
self
.
server
=
self
.
irker
.
irc
.
server
()
self
.
server
.
connect
(
self
.
servername
,
self
.
port
,
self
.
na
me
())
self
.
irker
.
debug
(
1
,
"
TTL bump (connection) at %s
"
%
time
.
ascti
me
())
self
.
last_active
=
time
.
time
()
self
.
last_active
=
time
.
time
()
self
.
server
.
connect
(
self
.
servername
,
self
.
port
,
self
.
name
())
elif
self
.
queue
.
empty
():
elif
self
.
queue
.
empty
():
if
time
.
time
()
>
self
.
last_active
+
TTL
:
if
time
.
time
()
>
self
.
last_active
+
TTL
:
self
.
server
.
part
(
"
#
"
+
channel
)
self
.
irker
.
debug
(
1
,
"
timing out inactive connection at %s
"
%
time
.
asctime
())
self
.
server
.
part
(
"
#
"
+
self
.
channel
)
self
.
server
=
None
self
.
server
=
None
break
break
else
:
else
:
...
@@ -79,6 +81,7 @@ class Session():
...
@@ -79,6 +81,7 @@ class Session():
self
.
server
.
join
(
"
#
"
+
self
.
channel
)
self
.
server
.
join
(
"
#
"
+
self
.
channel
)
self
.
server
.
privmsg
(
"
#
"
+
self
.
channel
,
message
)
self
.
server
.
privmsg
(
"
#
"
+
self
.
channel
,
message
)
self
.
last_active
=
time
.
time
()
self
.
last_active
=
time
.
time
()
self
.
irker
.
debug
(
1
,
"
TTL bump (transmission) at %s
"
%
time
.
asctime
())
self
.
queue
.
task_done
()
self
.
queue
.
task_done
()
def
name
(
self
):
def
name
(
self
):
"
Generate a unique name for this session.
"
"
Generate a unique name for this session.
"
...
@@ -142,6 +145,7 @@ if __name__ == '__main__':
...
@@ -142,6 +145,7 @@ if __name__ == '__main__':
server
=
SocketServer
.
TCPServer
((
host
,
port
),
MyTCPHandler
)
server
=
SocketServer
.
TCPServer
((
host
,
port
),
MyTCPHandler
)
try
:
try
:
server
.
serve_forever
()
server
.
serve_forever
()
except
k
eyboardInterrupt
:
except
K
eyboardInterrupt
:
pass
pass
# end
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