Skip to content

Commit 8424811

Browse files
author
Tony Crisci
committed
breaking: make socket and event things private
1 parent 4936704 commit 8424811

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

i3ipc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .model import (BarConfigReply, BarconfigUpdateEvent, BindingEvent, BindingInfo, CommandReply,
2-
ConfigReply, Event, Gaps, GenericEvent, MessageType, OutputReply, Rect,
3-
TickEvent, TickReply, VersionReply, WindowEvent, WorkspaceEvent, WorkspaceReply)
2+
ConfigReply, Gaps, GenericEvent, MessageType, OutputReply, Rect, TickEvent,
3+
TickReply, VersionReply, WindowEvent, WorkspaceEvent, WorkspaceReply)
44
from .con import Con
55
from .connection import Connection

i3ipc/connection.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@ def __init__(self, socket_path=None, auto_reconnect=False):
6767

6868
self._pubsub = PubSub(self)
6969
self.props = PropsObject(self)
70-
self.socket_path = socket_path
70+
self._socket_path = socket_path
7171
self._cmd_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
72-
self._cmd_socket.connect(self.socket_path)
72+
self._cmd_socket.connect(self._socket_path)
7373
self._cmd_lock = Lock()
7474
self._sub_socket = None
7575
self._sub_lock = Lock()
7676
self.auto_reconnect = auto_reconnect
7777
self._restarting = False
7878
self._quitting = False
7979

80+
@property
81+
def socket_path(self):
82+
return self._socket_path
83+
8084
def _pack(self, msg_type, payload):
8185
"""
8286
Packs the given message type and payload. Turns the resulting
@@ -141,7 +145,7 @@ def _wait_for_socket(self):
141145
# for the auto_reconnect feature only
142146
socket_path_exists = False
143147
for tries in range(0, 500):
144-
socket_path_exists = os.path.exists(self.socket_path)
148+
socket_path_exists = os.path.exists(self._socket_path)
145149
if socket_path_exists:
146150
break
147151
time.sleep(0.001)
@@ -166,7 +170,7 @@ def message(self, message_type, payload):
166170
raise e
167171

168172
self._cmd_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
169-
self._cmd_socket.connect(self.socket_path)
173+
self._cmd_socket.connect(self._socket_path)
170174
return self._ipc_send(self._cmd_socket, message_type, payload)
171175
finally:
172176
self._cmd_lock.release()
@@ -350,7 +354,7 @@ def send_tick(self, payload=""):
350354
data = self.message(MessageType.SEND_TICK, payload)
351355
return json.loads(data, object_hook=TickReply)
352356

353-
def subscribe(self, events):
357+
def _subscribe(self, events):
354358
events_obj = []
355359
if events & Event.WORKSPACE.value:
356360
events_obj.append("workspace")
@@ -420,9 +424,9 @@ def on(self, detailed_event, handler):
420424

421425
def _event_socket_setup(self):
422426
self._sub_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
423-
self._sub_socket.connect(self.socket_path)
427+
self._sub_socket.connect(self._socket_path)
424428

425-
self.subscribe(self.subscriptions)
429+
self._subscribe(self.subscriptions)
426430

427431
def _event_socket_teardown(self):
428432
if self._sub_socket:

0 commit comments

Comments
 (0)