PyEventEngine 0.3.0.post3__tar.gz → 0.3.0.post5__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.
@@ -1,109 +1,109 @@
1
- Metadata-Version: 2.1
2
- Name: PyEventEngine
3
- Version: 0.3.0.post3
4
- Summary: Basic event engine
5
- Home-page: https://github.com/BolunHan/PyEventEngine.git
6
- Author: Bolun.Han
7
- Author-email: Bolun.Han@outlook.com
8
- License: MIT
9
- Classifier: Programming Language :: Python :: 3.8
10
- Classifier: Programming Language :: Python :: 3.9
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Operating System :: OS Independent
15
- Requires-Python: >=3.8
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
-
19
- # PyEventEngine
20
-
21
- python native event engine
22
-
23
- # Install
24
-
25
- ```shell
26
- pip install git+https://github.com/BolunHan/PyEventEngine.git
27
- ```
28
-
29
- or
30
-
31
- ```shell
32
- pip install PyEventEngine
33
- ```
34
-
35
- # Use
36
-
37
- ## basic usage
38
-
39
- ```python
40
- # init event engine
41
- import time
42
- from event_engine import EventEngine, Topic
43
-
44
- EVENT_ENGINE = EventEngine()
45
- EVENT_ENGINE.start()
46
-
47
-
48
- # register handler
49
- def test_handler(msg, **kwargs):
50
- print(msg)
51
-
52
-
53
- EVENT_ENGINE.register_handler(topic=Topic('SimpleTopic'), handler=test_handler)
54
-
55
- # publish message
56
- EVENT_ENGINE.put(topic=Topic('SimpleTopic'), msg='topic called')
57
- time.sleep(1)
58
- EVENT_ENGINE.stop()
59
- ```
60
-
61
- ## regular topic
62
-
63
- ```python
64
- # init event engine
65
- import time
66
- from event_engine import EventEngine, Topic, RegularTopic
67
-
68
- EVENT_ENGINE = EventEngine()
69
- EVENT_ENGINE.start()
70
-
71
-
72
- # register handler
73
- def test_handler(msg, **kwargs):
74
- print(msg)
75
-
76
-
77
- EVENT_ENGINE.register_handler(topic=RegularTopic('RegularTopic.*'), handler=test_handler)
78
-
79
- # publish message
80
- EVENT_ENGINE.put(topic=Topic('RegularTopic.ChildTopic0'), msg='topic called')
81
- time.sleep(1)
82
- EVENT_ENGINE.stop()
83
- ```
84
-
85
- ## timer topic
86
-
87
- ```python
88
- # init event engine
89
- import time
90
- from event_engine import EventEngine, Topic, RegularTopic
91
-
92
- EVENT_ENGINE = EventEngine()
93
- EVENT_ENGINE.start()
94
-
95
-
96
- # register handler
97
- def test_handler(**kwargs):
98
- print(kwargs)
99
-
100
-
101
- topic = EVENT_ENGINE.get_timer(interval=1)
102
- EVENT_ENGINE.register_handler(topic=topic, handler=test_handler)
103
-
104
- # publish message
105
- time.sleep(5)
106
- EVENT_ENGINE.stop()
107
- ```
108
-
109
- See more advanced usage at .Demo
1
+ Metadata-Version: 2.1
2
+ Name: PyEventEngine
3
+ Version: 0.3.0.post5
4
+ Summary: Basic event engine
5
+ Home-page: https://github.com/BolunHan/PyEventEngine.git
6
+ Author: Bolun.Han
7
+ Author-email: Bolun.Han@outlook.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+
19
+ # PyEventEngine
20
+
21
+ python native event engine
22
+
23
+ # Install
24
+
25
+ ```shell
26
+ pip install git+https://github.com/BolunHan/PyEventEngine.git
27
+ ```
28
+
29
+ or
30
+
31
+ ```shell
32
+ pip install PyEventEngine
33
+ ```
34
+
35
+ # Use
36
+
37
+ ## basic usage
38
+
39
+ ```python
40
+ # init event engine
41
+ import time
42
+ from event_engine import EventEngine, Topic
43
+
44
+ EVENT_ENGINE = EventEngine()
45
+ EVENT_ENGINE.start()
46
+
47
+
48
+ # register handler
49
+ def test_handler(msg, **kwargs):
50
+ print(msg)
51
+
52
+
53
+ EVENT_ENGINE.register_handler(topic=Topic('SimpleTopic'), handler=test_handler)
54
+
55
+ # publish message
56
+ EVENT_ENGINE.put(topic=Topic('SimpleTopic'), msg='topic called')
57
+ time.sleep(1)
58
+ EVENT_ENGINE.stop()
59
+ ```
60
+
61
+ ## regular topic
62
+
63
+ ```python
64
+ # init event engine
65
+ import time
66
+ from event_engine import EventEngine, Topic, RegularTopic
67
+
68
+ EVENT_ENGINE = EventEngine()
69
+ EVENT_ENGINE.start()
70
+
71
+
72
+ # register handler
73
+ def test_handler(msg, **kwargs):
74
+ print(msg)
75
+
76
+
77
+ EVENT_ENGINE.register_handler(topic=RegularTopic('RegularTopic.*'), handler=test_handler)
78
+
79
+ # publish message
80
+ EVENT_ENGINE.put(topic=Topic('RegularTopic.ChildTopic0'), msg='topic called')
81
+ time.sleep(1)
82
+ EVENT_ENGINE.stop()
83
+ ```
84
+
85
+ ## timer topic
86
+
87
+ ```python
88
+ # init event engine
89
+ import time
90
+ from event_engine import EventEngine, Topic, RegularTopic
91
+
92
+ EVENT_ENGINE = EventEngine()
93
+ EVENT_ENGINE.start()
94
+
95
+
96
+ # register handler
97
+ def test_handler(**kwargs):
98
+ print(kwargs)
99
+
100
+
101
+ topic = EVENT_ENGINE.get_timer(interval=1)
102
+ EVENT_ENGINE.register_handler(topic=topic, handler=test_handler)
103
+
104
+ # publish message
105
+ time.sleep(5)
106
+ EVENT_ENGINE.stop()
107
+ ```
108
+
109
+ See more advanced usage at .Demo
@@ -1,109 +1,109 @@
1
- Metadata-Version: 2.1
2
- Name: PyEventEngine
3
- Version: 0.3.0.post3
4
- Summary: Basic event engine
5
- Home-page: https://github.com/BolunHan/PyEventEngine.git
6
- Author: Bolun.Han
7
- Author-email: Bolun.Han@outlook.com
8
- License: MIT
9
- Classifier: Programming Language :: Python :: 3.8
10
- Classifier: Programming Language :: Python :: 3.9
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Operating System :: OS Independent
15
- Requires-Python: >=3.8
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
-
19
- # PyEventEngine
20
-
21
- python native event engine
22
-
23
- # Install
24
-
25
- ```shell
26
- pip install git+https://github.com/BolunHan/PyEventEngine.git
27
- ```
28
-
29
- or
30
-
31
- ```shell
32
- pip install PyEventEngine
33
- ```
34
-
35
- # Use
36
-
37
- ## basic usage
38
-
39
- ```python
40
- # init event engine
41
- import time
42
- from event_engine import EventEngine, Topic
43
-
44
- EVENT_ENGINE = EventEngine()
45
- EVENT_ENGINE.start()
46
-
47
-
48
- # register handler
49
- def test_handler(msg, **kwargs):
50
- print(msg)
51
-
52
-
53
- EVENT_ENGINE.register_handler(topic=Topic('SimpleTopic'), handler=test_handler)
54
-
55
- # publish message
56
- EVENT_ENGINE.put(topic=Topic('SimpleTopic'), msg='topic called')
57
- time.sleep(1)
58
- EVENT_ENGINE.stop()
59
- ```
60
-
61
- ## regular topic
62
-
63
- ```python
64
- # init event engine
65
- import time
66
- from event_engine import EventEngine, Topic, RegularTopic
67
-
68
- EVENT_ENGINE = EventEngine()
69
- EVENT_ENGINE.start()
70
-
71
-
72
- # register handler
73
- def test_handler(msg, **kwargs):
74
- print(msg)
75
-
76
-
77
- EVENT_ENGINE.register_handler(topic=RegularTopic('RegularTopic.*'), handler=test_handler)
78
-
79
- # publish message
80
- EVENT_ENGINE.put(topic=Topic('RegularTopic.ChildTopic0'), msg='topic called')
81
- time.sleep(1)
82
- EVENT_ENGINE.stop()
83
- ```
84
-
85
- ## timer topic
86
-
87
- ```python
88
- # init event engine
89
- import time
90
- from event_engine import EventEngine, Topic, RegularTopic
91
-
92
- EVENT_ENGINE = EventEngine()
93
- EVENT_ENGINE.start()
94
-
95
-
96
- # register handler
97
- def test_handler(**kwargs):
98
- print(kwargs)
99
-
100
-
101
- topic = EVENT_ENGINE.get_timer(interval=1)
102
- EVENT_ENGINE.register_handler(topic=topic, handler=test_handler)
103
-
104
- # publish message
105
- time.sleep(5)
106
- EVENT_ENGINE.stop()
107
- ```
108
-
109
- See more advanced usage at .Demo
1
+ Metadata-Version: 2.1
2
+ Name: PyEventEngine
3
+ Version: 0.3.0.post5
4
+ Summary: Basic event engine
5
+ Home-page: https://github.com/BolunHan/PyEventEngine.git
6
+ Author: Bolun.Han
7
+ Author-email: Bolun.Han@outlook.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+
19
+ # PyEventEngine
20
+
21
+ python native event engine
22
+
23
+ # Install
24
+
25
+ ```shell
26
+ pip install git+https://github.com/BolunHan/PyEventEngine.git
27
+ ```
28
+
29
+ or
30
+
31
+ ```shell
32
+ pip install PyEventEngine
33
+ ```
34
+
35
+ # Use
36
+
37
+ ## basic usage
38
+
39
+ ```python
40
+ # init event engine
41
+ import time
42
+ from event_engine import EventEngine, Topic
43
+
44
+ EVENT_ENGINE = EventEngine()
45
+ EVENT_ENGINE.start()
46
+
47
+
48
+ # register handler
49
+ def test_handler(msg, **kwargs):
50
+ print(msg)
51
+
52
+
53
+ EVENT_ENGINE.register_handler(topic=Topic('SimpleTopic'), handler=test_handler)
54
+
55
+ # publish message
56
+ EVENT_ENGINE.put(topic=Topic('SimpleTopic'), msg='topic called')
57
+ time.sleep(1)
58
+ EVENT_ENGINE.stop()
59
+ ```
60
+
61
+ ## regular topic
62
+
63
+ ```python
64
+ # init event engine
65
+ import time
66
+ from event_engine import EventEngine, Topic, RegularTopic
67
+
68
+ EVENT_ENGINE = EventEngine()
69
+ EVENT_ENGINE.start()
70
+
71
+
72
+ # register handler
73
+ def test_handler(msg, **kwargs):
74
+ print(msg)
75
+
76
+
77
+ EVENT_ENGINE.register_handler(topic=RegularTopic('RegularTopic.*'), handler=test_handler)
78
+
79
+ # publish message
80
+ EVENT_ENGINE.put(topic=Topic('RegularTopic.ChildTopic0'), msg='topic called')
81
+ time.sleep(1)
82
+ EVENT_ENGINE.stop()
83
+ ```
84
+
85
+ ## timer topic
86
+
87
+ ```python
88
+ # init event engine
89
+ import time
90
+ from event_engine import EventEngine, Topic, RegularTopic
91
+
92
+ EVENT_ENGINE = EventEngine()
93
+ EVENT_ENGINE.start()
94
+
95
+
96
+ # register handler
97
+ def test_handler(**kwargs):
98
+ print(kwargs)
99
+
100
+
101
+ topic = EVENT_ENGINE.get_timer(interval=1)
102
+ EVENT_ENGINE.register_handler(topic=topic, handler=test_handler)
103
+
104
+ # publish message
105
+ time.sleep(5)
106
+ EVENT_ENGINE.stop()
107
+ ```
108
+
109
+ See more advanced usage at .Demo
@@ -8,6 +8,7 @@ PyEventEngine.egg-info/dependency_links.txt
8
8
  PyEventEngine.egg-info/top_level.txt
9
9
  event_engine/__init__.py
10
10
  event_engine/cpp/topic_api.cpp
11
+ event_engine/cpp/topic_api.cpp
11
12
  event_engine/native/__init__.py
12
13
  event_engine/native/_event.py
13
14
  event_engine/native/_topic.py
@@ -0,0 +1,3 @@
1
+ __version__ = '0.3.0.post5'
2
+
3
+ from .native import *
@@ -281,6 +281,10 @@ class EventEngineBase(object):
281
281
  def buffer_size(self):
282
282
  return self._buffer_size
283
283
 
284
+ @property
285
+ def active(self) -> bool:
286
+ return self._active
287
+
284
288
 
285
289
  class EventEngine(EventEngineBase):
286
290
  EventHook = EventHook
@@ -86,6 +86,9 @@ class PatternTopic(Topic):
86
86
  topic for event hook. e.g. "TickData.{symbol}.{market}.{flag}"
87
87
  """
88
88
 
89
+ class NotMatchError(Topic.Error):
90
+ pass
91
+
89
92
  def __init__(self, pattern: str):
90
93
  super().__init__(topic=pattern)
91
94
 
@@ -106,7 +109,7 @@ class PatternTopic(Topic):
106
109
  # raise Topic.Error(f'pattern {pattern} not in string {target} found!')
107
110
 
108
111
  @classmethod
109
- def extract_mapping(cls, target: str, pattern: str):
112
+ def extract_mapping(cls, target: str, pattern: str) -> dict[str, str]:
110
113
  dictionary = {}
111
114
 
112
115
  result_parts = target.split('.')
@@ -114,17 +117,17 @@ class PatternTopic(Topic):
114
117
 
115
118
  # Check if the number of parts in result and pattern are the same
116
119
  if len(result_parts) != len(pattern_parts):
117
- return dictionary
120
+ raise cls.NotMatchError(f'Target {target} not match with pattern {pattern}.')
118
121
 
119
122
  # Generate the mapping dictionary
120
- for result_part, pattern_part in zip(result_parts, pattern_parts): # type: str
123
+ for result_part, pattern_part in zip(result_parts, pattern_parts):
121
124
  if pattern_part[0] == '{' and pattern_part[-1] == '}':
122
- content = pattern_part[1:-1]
125
+ content: str = pattern_part[1:-1]
123
126
  dictionary[content] = result_part
124
127
  else:
125
128
  if result_part != pattern_part:
126
129
  dictionary.clear()
127
- break
130
+ raise cls.NotMatchError(f'Target {target} not match with pattern {pattern}.')
128
131
 
129
132
  return dictionary
130
133
 
@@ -145,7 +148,7 @@ class PatternTopic(Topic):
145
148
  match = Topic(topic=topic)
146
149
  match.update(keyword_dict)
147
150
  return match
148
- except self.Error as _:
151
+ except self.NotMatchError as _:
149
152
  return None
150
153
 
151
154
  @property
@@ -1,7 +1,7 @@
1
- [metadata]
2
- description-file = README.md
3
-
4
- [egg_info]
5
- tag_build =
6
- tag_date = 0
7
-
1
+ [metadata]
2
+ description-file = README.md
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -1,3 +0,0 @@
1
- __version__ = '0.3.0.post3'
2
-
3
- from .native import *