drifTech-lib 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of drifTech-lib might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drifTech-lib
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Common files/functions across most drifTech software
5
5
  Author: driftbluestone
6
6
  Author-email: driftbluestone <driftbluestone@gmail.com>
@@ -8,7 +8,7 @@ build-backend = "uv_build"
8
8
 
9
9
  [project]
10
10
  name = "drifTech-lib"
11
- version = "0.2.4"
11
+ version = "0.2.6"
12
12
  description = "Common files/functions across most drifTech software"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.14"
@@ -8,7 +8,7 @@ build-backend = "uv_build"
8
8
 
9
9
  [project]
10
10
  name = "drifTech-lib"
11
- version = "0.2.4"
11
+ version = "0.2.6"
12
12
  authors = [{name = "driftbluestone", email = "driftbluestone@gmail.com"}]
13
13
  description = "Common files/functions across most drifTech software"
14
14
  readme = "README.md"
@@ -17,6 +17,7 @@ def table(name: str, columns: list[str]):
17
17
  Create a table. Columns should be formatted like `column_name TYPE` e.g. `server_id BIGINT PRIMARY KEY` or `data JSONB`
18
18
  """
19
19
  run(f"CREATE TABLE IF NOT EXISTS {SCHEMA.as_string()}.{name} ({", ".join(columns)});")
20
+ logger.info(f"Created table {name} if it didn't already exist")
20
21
 
21
22
  def check_connection():
22
23
  cursor.execute("SELECT version();")
@@ -131,3 +132,4 @@ def start(schema: str, host: str, name: str, user: str, password: str, port: int
131
132
  check_connection()
132
133
  logger.info("Connected to database.")
133
134
  run(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA.as_string()};")
135
+ logger.info(f"Created schema {schema} if it didn't already exist")
@@ -2,7 +2,9 @@ import asyncio, logging
2
2
  logger = logging.getLogger("ipc:server")
3
3
  __all__ = ["start"]
4
4
 
5
- async def start(HOST, PORT):
5
+ open_connections = 1
6
+
7
+ async def start(HOST = "127.0.0.1", PORT = 8000):
6
8
  server = await asyncio.start_server(interface, HOST, PORT)
7
9
  logger.info(f"[LISTENING] Server is running on {HOST}:{PORT}")
8
10
  async with server:
@@ -10,7 +12,8 @@ async def start(HOST, PORT):
10
12
 
11
13
  async def interface(reader: asyncio.StreamReader, writer: asyncio.StreamWriter):
12
14
  addr = writer.get_extra_info("peername")
13
- logger.info(f"[CONNECTION]: Connection opened for {addr}")
15
+ logger.info(f"[CONNECTION] Connection opened for {addr} #{open_connections}")
16
+ open_connections += 1
14
17
  try:
15
18
  while True:
16
19
  data = await reader.read(1024)
@@ -20,10 +23,12 @@ async def interface(reader: asyncio.StreamReader, writer: asyncio.StreamWriter):
20
23
  writer.write(b"Message processed")
21
24
  await writer.drain() # Ensure data is flushed to the network buffer
22
25
  except (asyncio.CancelledError, ConnectionResetError, BrokenPipeError, OSError):
23
- logger.info(f"[DISCONNECTED] Connection closed for {addr}")
26
+ open_connections -= 1
27
+ logger.info(f"[DISCONNECTED] Connection closed for {addr} #{open_connections-1}")
24
28
  writer.close()
25
29
  await writer.wait_closed()
26
30
  finally:
27
- logger.info(f"[DISCONNECTED] Connection closed for {addr}")
31
+ open_connections -= 1
32
+ logger.info(f"[DISCONNECTED] Connection closed for {addr} #{open_connections-1}")
28
33
  writer.close()
29
34
  await writer.wait_closed()
File without changes
File without changes