Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleted macOS Action tests and outdated Python 3.5 Action tests #10

Closed
wants to merge 10 commits into from
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
pull_request:
branches: [ master ]
jobs:
tests:
tests_Ubuntu:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9 ]
os: [ ubuntu-latest, macOS-latest ]
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
os: [ ubuntu-latest ]

steps:
- name: Checkout
Expand Down
17 changes: 9 additions & 8 deletions postgresql_watcher/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def casbin_subscription(
process_conn: connection.PipeConnection,
process_conn: Pipe,
host: str,
user: str,
password: str,
Expand Down Expand Up @@ -45,12 +45,14 @@ def __init__(
channel_name: Optional[str] = POSTGRESQL_CHANNEL_NAME,
start_process: Optional[bool] = True,
):
self.update_callback = None
self.parent_conn: Pipe = None
self.host = host
self.port = port
self.user = user
self.password = password
self.channel_name = channel_name
self.subscribed_process, self.parent_conn = self.create_subscriber_process(
self.subscribed_process = self.create_subscriber_process(
start_process
)

Expand All @@ -60,6 +62,8 @@ def create_subscriber_process(
delay: Optional[int] = 2,
):
parent_conn, child_conn = Pipe()
if not self.parent_conn:
self.parent_conn = parent_conn
p = Process(
target=casbin_subscription,
args=(
Expand All @@ -76,12 +80,9 @@ def create_subscriber_process(
if start_process:
p.start()
self.should_reload()
return p, parent_conn
return p

def update_callback(self):
print("callback called because casbin role updated")

def set_update_callback(self, fn_name: Any):
def set_update_callback(self, fn_name: Callable):
print("runtime is set update callback",fn_name)
self.update_callback = fn_name

Expand Down Expand Up @@ -116,4 +117,4 @@ def should_reload(self):
self.subscribed_process, self.parent_conn = self.create_subscriber_process(
delay=10
)
return False
return False
4 changes: 2 additions & 2 deletions tests/test_postgresql_watcher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
from postgresql_watcher import PostgresqlWatcher
from multiprocessing import connection, context
from multiprocessing.connection import PipeConnection

# Warning!!! , Please setup yourself config
HOST = "127.0.0.1"
Expand All @@ -10,8 +11,7 @@


def get_watcher():
pg_watcher = PostgresqlWatcher(host=HOST, port=PORT, user=USER, password=PASSWORD)
return pg_watcher
return PostgresqlWatcher(host=HOST, port=PORT, user=USER, password=PASSWORD)


pg_watcher = get_watcher()
Expand Down