Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HELpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
HELpy
Commits
9c92af97
Commit
9c92af97
authored
2 months ago
by
Krzysztof Mochocki
Browse files
Options
Downloads
Patches
Plain Diff
Add with-statement support for handles
parent
b9e7e0f0
No related branches found
No related tags found
1 merge request
!73
Clive integration related fixes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beekeepy/beekeepy/_handle/beekeeper.py
+3
-9
3 additions, 9 deletions
beekeepy/beekeepy/_handle/beekeeper.py
helpy/helpy/_handles/abc/handle.py
+9
-2
9 additions, 2 deletions
helpy/helpy/_handles/abc/handle.py
with
12 additions
and
11 deletions
beekeepy/beekeepy/_handle/beekeeper.py
+
3
−
9
View file @
9c92af97
...
...
@@ -17,7 +17,7 @@ from beekeepy.exceptions import (
BeekeeperFailedToStartNotReadyOnTimeError
,
BeekeeperIsNotRunningError
,
)
from
helpy
import
ContextAsync
,
ContextSync
,
HttpUrl
from
helpy
import
HttpUrl
from
helpy._communication.universal_notification_server
import
(
UniversalNotificationServer
,
)
...
...
@@ -195,7 +195,7 @@ class BeekeeperCommon(BeekeeperNotificationCallbacks, ABC):
def
_get_settings
(
self
)
->
Settings
:
...
class
Beekeeper
(
BeekeeperCommon
,
SyncRemoteBeekeeper
,
ContextSync
[
"
Beekeeper
"
]
):
class
Beekeeper
(
BeekeeperCommon
,
SyncRemoteBeekeeper
):
def
run
(
self
,
*
,
additional_cli_arguments
:
BeekeeperArguments
|
None
=
None
)
->
None
:
self
.
_clear_session
()
with
self
.
update_settings
()
as
settings
:
...
...
@@ -217,15 +217,12 @@ class Beekeeper(BeekeeperCommon, SyncRemoteBeekeeper, ContextSync["Beekeeper"]):
self
.
run
()
return
self
def
_finally
(
self
)
->
None
:
self
.
teardown
()
def
teardown
(
self
)
->
None
:
self
.
_close
()
super
().
teardown
()
class
AsyncBeekeeper
(
BeekeeperCommon
,
AsyncRemoteBeekeeper
,
ContextAsync
[
"
AsyncBeekeeper
"
]
):
class
AsyncBeekeeper
(
BeekeeperCommon
,
AsyncRemoteBeekeeper
):
def
run
(
self
,
*
,
additional_cli_arguments
:
BeekeeperArguments
|
None
=
None
)
->
None
:
self
.
_clear_session
()
with
self
.
update_settings
()
as
settings
:
...
...
@@ -247,9 +244,6 @@ class AsyncBeekeeper(BeekeeperCommon, AsyncRemoteBeekeeper, ContextAsync["AsyncB
self
.
run
()
return
self
async
def
_afinally
(
self
)
->
None
:
self
.
teardown
()
def
teardown
(
self
)
->
None
:
self
.
_close
()
super
().
teardown
()
This diff is collapsed.
Click to expand it.
helpy/helpy/_handles/abc/handle.py
+
9
−
2
View file @
9c92af97
...
...
@@ -9,6 +9,7 @@ from helpy._communication.aiohttp_communicator import AioHttpCommunicator
from
helpy._communication.request_communicator
import
RequestCommunicator
from
helpy._handles.build_json_rpc_call
import
build_json_rpc_call
from
helpy._handles.settings
import
Settings
from
helpy._interfaces.context
import
SelfContextAsync
,
SelfContextSync
from
helpy._interfaces.settings_holder
import
UniqueSettingsHolder
from
helpy._interfaces.stopwatch
import
Stopwatch
from
schemas.jsonrpc
import
ExpectResultT
,
JSONRPCResult
,
get_response_model
...
...
@@ -117,7 +118,7 @@ class AbstractHandle(UniqueSettingsHolder[Settings], ABC, Generic[ApiT]):
self
.
_overseer
.
teardown
()
class
AbstractAsyncHandle
(
AbstractHandle
[
ApiT
],
ABC
):
class
AbstractAsyncHandle
(
AbstractHandle
[
ApiT
],
SelfContextAsync
,
ABC
):
"""
Base class for service handlers that uses asynchronous communication.
"""
async
def
_async_send
(
...
...
@@ -143,8 +144,11 @@ class AbstractAsyncHandle(AbstractHandle[ApiT], ABC):
async
def
batch
(
self
,
*
,
delay_error_on_data_access
:
bool
=
False
)
->
AsyncBatchHandle
[
Any
]:
"""
Returns async batch handle.
"""
async
def
_afinally
(
self
)
->
None
:
self
.
teardown
()
class
AbstractSyncHandle
(
AbstractHandle
[
ApiT
],
ABC
):
class
AbstractSyncHandle
(
AbstractHandle
[
ApiT
],
SelfContextSync
,
ABC
):
"""
Base class for service handlers that uses synchronous communication.
"""
def
_send
(
self
,
*
,
endpoint
:
str
,
params
:
str
,
expected_type
:
type
[
ExpectResultT
])
->
JSONRPCResult
[
ExpectResultT
]:
...
...
@@ -167,3 +171,6 @@ class AbstractSyncHandle(AbstractHandle[ApiT], ABC):
@abstractmethod
def
batch
(
self
,
*
,
delay_error_on_data_access
:
bool
=
False
)
->
SyncBatchHandle
[
Any
]:
"""
Returns sync batch handle.
"""
def
_finally
(
self
)
->
None
:
self
.
teardown
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment