Skip to content

Commit

Permalink
Merge pull request #43 from vkottler/dev/expose-socket
Browse files Browse the repository at this point in the history
Expose a socket attribute
  • Loading branch information
vkottler authored Feb 17, 2023
2 parents 2b532f3 + bdc2130 commit 7346278
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.0
hash=426b03bac536323cf15f4d053e9df8f5
hash=cc8d38e45a45d9b9ccebbd439d7d074a
=====================================
-->

# runtimepy ([0.14.3](https://pypi.org/project/runtimepy/))
# runtimepy ([0.14.4](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 0
minor: 14
patch: 3
patch: 4
entry: runtimepy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "0.14.3"
version = "0.14.4"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.7"
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.0
# hash=a6ef11ec5c9df99f021d2c6f3c71c48f
# hash=b3d016e9b501e91b63a65f1f5869b4c2
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "0.14.3"
VERSION = "0.14.4"
7 changes: 7 additions & 0 deletions runtimepy/net/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

# built-in
import asyncio as _asyncio
from socket import SocketType as _SocketType
from typing import Optional as _Optional
from typing import cast as _cast

# internal
from runtimepy.net import IpHost as _IpHost
Expand Down Expand Up @@ -42,6 +44,11 @@ def __init__(self, transport: _asyncio.BaseTransport) -> None:
# None).
self.remote_address = self._remote_address()

@property
def socket(self) -> _SocketType:
"""Get this instance's underlying socket."""
return _cast(_SocketType, self._transport.get_extra_info("socket"))

def _remote_address(self) -> _Optional[_IpHost]:
"""Get a possible remote address for this connection."""

Expand Down
3 changes: 3 additions & 0 deletions tests/net/udp/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ async def test_udp_connection_basic():

conn1, conn2 = await SampleConnection.create_pair()

assert conn1.socket
assert conn2.socket

conn1.send_text("Hello!")
conn2.send_text("Hello!")
for idx in range(10):
Expand Down

0 comments on commit 7346278

Please sign in to comment.