Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
67d4c13f
Commit
67d4c13f
authored
Feb 14, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old TCP draft.
parent
32f6ee7d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
71 deletions
+0
-71
mitogen/tcp.py
mitogen/tcp.py
+0
-71
No files found.
mitogen/tcp.py
deleted
100644 → 0
View file @
32f6ee7d
# Copyright 2017, David Wilson
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
Functionality to allow a slave context to reconnect back to its master using a
plain TCP connection.
"""
import
socket
import
mitogen.core
from
mitogen.core
import
LOG
class
Listener
(
mitogen
.
core
.
BasicStream
):
def
__init__
(
self
,
broker
,
address
=
None
,
backlog
=
30
):
self
.
_broker
=
broker
self
.
_sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
_sock
.
bind
(
address
or
(
'0.0.0.0'
,
0
))
self
.
_sock
.
listen
(
backlog
)
mitogen
.
core
.
set_cloexec
(
self
.
_sock
.
fileno
())
self
.
address
=
self
.
_sock
.
getsockname
()
self
.
receive_side
=
mitogen
.
core
.
Side
(
self
,
self
.
_sock
.
fileno
())
broker
.
start_receive
(
self
)
def
on_receive
(
self
,
broker
):
sock
,
addr
=
self
.
_sock
.
accept
()
context
=
mitogen
.
core
.
Context
(
self
.
_broker
,
name
=
addr
)
stream
=
mitogen
.
core
.
Stream
(
context
)
stream
.
accept
(
sock
.
fileno
(),
sock
.
fileno
())
def
listen
(
broker
,
address
=
None
,
backlog
=
30
):
"""Listen on `address` for connections from newly spawned contexts."""
return
Listener
(
broker
,
address
,
backlog
)
def
connect
(
context
):
"""Connect to a Broker at the address specified in our associated
Context."""
LOG
.
debug
(
'%s.connect()'
,
__name__
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
receive_side
=
mitogen
.
core
.
Side
(
self
,
sock
.
fileno
())
self
.
transmit_side
=
mitogen
.
core
.
Side
(
self
,
sock
.
fileno
())
sock
.
connect
(
self
.
_context
.
parent_addr
)
self
.
enqueue
(
0
,
self
.
_context
.
name
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment