Skip to content

Commit ef0f88f

Browse files
Internal code restructure (no functional changes)
1 parent d222f4c commit ef0f88f

32 files changed

+864
-838
lines changed

docs/api.rst

Lines changed: 12 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,141 +6,86 @@ API Reference
66

77
.. module:: socketio
88

9-
``SimpleClient`` class
10-
----------------------
11-
129
.. autoclass:: SimpleClient
1310
:members:
14-
15-
``AsyncSimpleClient`` class
16-
---------------------------
11+
:inherited-members:
1712

1813
.. autoclass:: AsyncSimpleClient
1914
:members:
20-
21-
``Client`` class
22-
----------------
15+
:inherited-members:
2316

2417
.. autoclass:: Client
2518
:members:
26-
27-
``AsyncClient`` class
28-
---------------------
19+
:inherited-members:
2920

3021
.. autoclass:: AsyncClient
3122
:members:
3223
:inherited-members:
3324

34-
``Server`` class
35-
----------------
36-
3725
.. autoclass:: Server
3826
:members:
39-
40-
``AsyncServer`` class
41-
---------------------
27+
:inherited-members:
4228

4329
.. autoclass:: AsyncServer
4430
:members:
4531
:inherited-members:
4632

47-
``ConnectionRefusedError`` class
48-
--------------------------------
49-
5033
.. autoclass:: socketio.exceptions.ConnectionRefusedError
5134
:members:
5235

53-
``WSGIApp`` class
54-
-----------------
55-
5636
.. autoclass:: WSGIApp
5737
:members:
5838

59-
``ASGIApp`` class
60-
-----------------
61-
6239
.. autoclass:: ASGIApp
6340
:members:
6441

65-
``Middleware`` class (deprecated)
66-
---------------------------------
67-
6842
.. autoclass:: Middleware
6943
:members:
7044

71-
``ClientNamespace`` class
72-
-------------------------
73-
7445
.. autoclass:: ClientNamespace
7546
:members:
7647
:inherited-members:
7748

78-
``Namespace`` class
79-
-------------------
80-
8149
.. autoclass:: Namespace
8250
:members:
8351
:inherited-members:
8452

85-
``AsyncClientNamespace`` class
86-
------------------------------
87-
8853
.. autoclass:: AsyncClientNamespace
8954
:members:
9055
:inherited-members:
9156

92-
``AsyncNamespace`` class
93-
------------------------
94-
9557
.. autoclass:: AsyncNamespace
9658
:members:
9759
:inherited-members:
9860

99-
``BaseManager`` class
100-
---------------------
101-
102-
.. autoclass:: BaseManager
61+
.. autoclass:: Manager
10362
:members:
104-
105-
``PubSubManager`` class
106-
-----------------------
63+
:inherited-members:
10764

10865
.. autoclass:: PubSubManager
10966
:members:
110-
111-
``KombuManager`` class
112-
----------------------
67+
:inherited-members:
11368

11469
.. autoclass:: KombuManager
11570
:members:
116-
117-
``RedisManager`` class
118-
----------------------
71+
:inherited-members:
11972

12073
.. autoclass:: RedisManager
12174
:members:
122-
123-
``KafkaManager`` class
124-
----------------------
75+
:inherited-members:
12576

12677
.. autoclass:: KafkaManager
12778
:members:
128-
129-
``AsyncManager`` class
130-
----------------------
79+
:inherited-members:
13180

13281
.. autoclass:: AsyncManager
13382
:members:
13483
:inherited-members:
13584

136-
``AsyncRedisManager`` class
137-
---------------------------
138-
13985
.. autoclass:: AsyncRedisManager
14086
:members:
141-
142-
``AsyncAioPikaManager`` class
143-
-----------------------------
87+
:inherited-members:
14488

14589
.. autoclass:: AsyncAioPikaManager
14690
:members:
91+
:inherited-members:

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
'sphinx.ext.autodoc',
4343
]
4444

45-
autodoc_member_order = 'bysource'
45+
autodoc_member_order = 'alphabetical'
4646

4747
# Add any paths that contain templates here, relative to this directory.
4848
templates_path = ['_templates']
@@ -61,7 +61,7 @@
6161
#
6262
# This is also used if you do content translation via gettext catalogs.
6363
# Usually you set "language" from the command line for these cases.
64-
language = None
64+
language = 'en'
6565

6666
# List of patterns, relative to source directory, that match files and
6767
# directories to ignore when looking for source files.

src/socketio/__init__.py

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import sys
2-
31
from .client import Client
42
from .simple_client import SimpleClient
5-
from .base_manager import BaseManager
3+
from .manager import Manager
64
from .pubsub_manager import PubSubManager
75
from .kombu_manager import KombuManager
86
from .redis_manager import RedisManager
@@ -12,29 +10,19 @@
1210
from .namespace import Namespace, ClientNamespace
1311
from .middleware import WSGIApp, Middleware
1412
from .tornado import get_tornado_handler
15-
if sys.version_info >= (3, 5): # pragma: no cover
16-
from .asyncio_client import AsyncClient
17-
from .asyncio_simple_client import AsyncSimpleClient
18-
from .asyncio_server import AsyncServer
19-
from .asyncio_manager import AsyncManager
20-
from .asyncio_namespace import AsyncNamespace, AsyncClientNamespace
21-
from .asyncio_redis_manager import AsyncRedisManager
22-
from .asyncio_aiopika_manager import AsyncAioPikaManager
23-
from .asgi import ASGIApp
24-
else: # pragma: no cover
25-
AsyncSimpleClient = None
26-
AsyncClient = None
27-
AsyncServer = None
28-
AsyncManager = None
29-
AsyncNamespace = None
30-
AsyncRedisManager = None
31-
AsyncAioPikaManager = None
13+
from .async_client import AsyncClient
14+
from .async_simple_client import AsyncSimpleClient
15+
from .async_server import AsyncServer
16+
from .async_manager import AsyncManager
17+
from .async_namespace import AsyncNamespace, AsyncClientNamespace
18+
from .async_redis_manager import AsyncRedisManager
19+
from .async_aiopika_manager import AsyncAioPikaManager
20+
from .asgi import ASGIApp
3221

33-
__all__ = ['SimpleClient', 'Client', 'Server', 'BaseManager', 'PubSubManager',
22+
__all__ = ['SimpleClient', 'Client', 'Server', 'Manager', 'PubSubManager',
3423
'KombuManager', 'RedisManager', 'ZmqManager', 'KafkaManager',
35-
'Namespace', 'ClientNamespace', 'WSGIApp', 'Middleware']
36-
if AsyncServer is not None: # pragma: no cover
37-
__all__ += ['AsyncSimpleClient', 'AsyncClient', 'AsyncServer',
38-
'AsyncNamespace', 'AsyncClientNamespace', 'AsyncManager',
39-
'AsyncRedisManager', 'ASGIApp', 'get_tornado_handler',
40-
'AsyncAioPikaManager']
24+
'Namespace', 'ClientNamespace', 'WSGIApp', 'Middleware',
25+
'AsyncSimpleClient', 'AsyncClient', 'AsyncServer',
26+
'AsyncNamespace', 'AsyncClientNamespace', 'AsyncManager',
27+
'AsyncRedisManager', 'ASGIApp', 'get_tornado_handler',
28+
'AsyncAioPikaManager']

src/socketio/asyncio_aiopika_manager.py renamed to src/socketio/async_aiopika_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import pickle
33

4-
from socketio.asyncio_pubsub_manager import AsyncPubSubManager
4+
from .async_pubsub_manager import AsyncPubSubManager
55

66
try:
77
import aio_pika

src/socketio/asyncio_client.py renamed to src/socketio/async_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import engineio
66

7-
from . import client
7+
from . import base_client
88
from . import exceptions
99
from . import packet
1010

1111
default_logger = logging.getLogger('socketio.client')
1212

1313

14-
class AsyncClient(client.Client):
14+
class AsyncClient(base_client.BaseClient):
1515
"""A Socket.IO client for asyncio.
1616
1717
This class implements a fully compliant Socket.IO web client with support
@@ -456,7 +456,7 @@ async def _handle_reconnect(self):
456456
if self._reconnect_abort is None: # pragma: no cover
457457
self._reconnect_abort = self.eio.create_event()
458458
self._reconnect_abort.clear()
459-
client.reconnecting_clients.append(self)
459+
base_client.reconnecting_clients.append(self)
460460
attempt_count = 0
461461
current_delay = self.reconnection_delay
462462
while True:
@@ -499,7 +499,7 @@ async def _handle_reconnect(self):
499499
await self._trigger_event('__disconnect_final',
500500
namespace=n)
501501
break
502-
client.reconnecting_clients.remove(self)
502+
base_client.reconnecting_clients.remove(self)
503503

504504
async def _handle_eio_connect(self):
505505
"""Handle the Engine.IO connection event."""

src/socketio/asyncio_manager.py renamed to src/socketio/async_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ async def disconnect(self, sid, namespace, **kwargs):
6767
6868
Note: this method is a coroutine.
6969
"""
70-
return super().disconnect(sid, namespace, **kwargs)
70+
return self.basic_disconnect(sid, namespace, **kwargs)
7171

7272
async def enter_room(self, sid, namespace, room, eio_sid=None):
7373
"""Add a client to a room.
7474
7575
Note: this method is a coroutine.
7676
"""
77-
return super().enter_room(sid, namespace, room, eio_sid=eio_sid)
77+
return self.basic_enter_room(sid, namespace, room, eio_sid=eio_sid)
7878

7979
async def leave_room(self, sid, namespace, room):
8080
"""Remove a client from a room.
8181
8282
Note: this method is a coroutine.
8383
"""
84-
return super().leave_room(sid, namespace, room)
84+
return self.basic_leave_room(sid, namespace, room)
8585

8686
async def close_room(self, room, namespace):
8787
"""Remove all participants from a room.
8888
8989
Note: this method is a coroutine.
9090
"""
91-
return super().close_room(room, namespace)
91+
return self.basic_close_room(room, namespace)
9292

9393
async def trigger_callback(self, sid, id, data):
9494
"""Invoke an application callback.

src/socketio/asyncio_namespace.py renamed to src/socketio/async_namespace.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import asyncio
22

3-
from socketio import namespace
3+
from socketio import base_namespace
44

55

6-
class AsyncNamespace(namespace.Namespace):
6+
class AsyncNamespace(base_namespace.BaseServerNamespace):
77
"""Base class for asyncio server-side class-based namespaces.
88
99
A class-based namespace is a class that contains all the event handlers
@@ -168,7 +168,7 @@ async def disconnect(self, sid, namespace=None):
168168
sid, namespace=namespace or self.namespace)
169169

170170

171-
class AsyncClientNamespace(namespace.ClientNamespace):
171+
class AsyncClientNamespace(base_namespace.BaseClientNamespace):
172172
"""Base class for asyncio client-side class-based namespaces.
173173
174174
A class-based namespace is a class that contains all the event handlers

src/socketio/asyncio_pubsub_manager.py renamed to src/socketio/async_pubsub_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from engineio import json
66
import pickle
77

8-
from .asyncio_manager import AsyncManager
8+
from .async_manager import AsyncManager
99

1010

1111
class AsyncPubSubManager(AsyncManager):

src/socketio/asyncio_redis_manager.py renamed to src/socketio/async_redis_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
aioredis = None
1313
RedisError = None
1414

15-
from .asyncio_pubsub_manager import AsyncPubSubManager
15+
from .async_pubsub_manager import AsyncPubSubManager
1616

1717

1818
class AsyncRedisManager(AsyncPubSubManager): # pragma: no cover

src/socketio/asyncio_server.py renamed to src/socketio/async_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import engineio
44

5-
from . import asyncio_manager
5+
from . import async_manager
6+
from . import base_server
67
from . import exceptions
78
from . import packet
8-
from . import server
99

1010

11-
class AsyncServer(server.Server):
11+
class AsyncServer(base_server.BaseServer):
1212
"""A Socket.IO server for asyncio.
1313
1414
This class implements a fully compliant Socket.IO web server with support
@@ -104,7 +104,7 @@ class AsyncServer(server.Server):
104104
def __init__(self, client_manager=None, logger=False, json=None,
105105
async_handlers=True, namespaces=None, **kwargs):
106106
if client_manager is None:
107-
client_manager = asyncio_manager.AsyncManager()
107+
client_manager = async_manager.AsyncManager()
108108
super().__init__(client_manager=client_manager, logger=logger,
109109
json=json, async_handlers=async_handlers,
110110
namespaces=namespaces, **kwargs)

0 commit comments

Comments
 (0)