Skip to content

Commit 5a2db6e

Browse files
committed
improved
1 parent 3fba030 commit 5a2db6e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
22
[![mypy](https://github.com/guangrei/syncio/actions/workflows/mypy_check.yml/badge.svg)](https://github.com/guangrei/syncio/actions)
33

4+
[![Downloads](https://static.pepy.tech/badge/syncio)](https://pepy.tech/project/syncio)
5+
[![Downloads](https://static.pepy.tech/badge/syncio/month)](https://pepy.tech/project/syncio)
6+
[![Downloads](https://static.pepy.tech/badge/syncio/week)](https://pepy.tech/project/syncio)
7+
48
Syncio is inspired by `asyncio`. you can easy to create task and gather with `syncio.gather()` (multiprocessing) or `syncio.thread_gather()` (threading).
59

610
## Example

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
setup(
1515
name="syncio",
16-
version="v0.0.1",
17-
description="type safe for synchronous python concurrently",
16+
version="v0.0.2",
17+
description="type safety for synchronous concurrent task",
1818
long_description=long_description,
1919
long_description_content_type="text/markdown",
2020
author="guangrei",

syncio/Task.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# -*-coding:utf8;-*-
22
from abc import ABC, abstractmethod
3-
from typing import Callable, List, Any, Iterator, Dict
3+
from typing import Callable, Tuple, List, Any, Iterator, Dict
44
from typing_extensions import Self
55

66

77
class NewTask(ABC):
88
func: Callable[..., Any]
9-
args: List[Any]
9+
args: Tuple[Any]
1010
kwargs: Dict[str, Any]
1111

1212
@abstractmethod
13-
def __init__(self, func: Callable[..., Any]) -> None:
13+
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None:
1414
pass
1515

1616
@abstractmethod
@@ -19,25 +19,21 @@ def __call__(self, *args: Any, **kwargs: Any) -> Self:
1919

2020

2121
class create_task(NewTask):
22-
def __init__(self, func: Callable[..., Any]) -> None:
22+
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None:
2323
self.func = func
24-
self.args: List[Any] = []
25-
self.kwargs: Dict[str, Any] = {}
24+
self.args: Tuple[Any] = args
25+
self.kwargs: Dict[str, Any] = kwargs
2626

2727
def __call__(self, *args: Any, **kwargs: Any) -> Self:
28-
self.args = list(args)
29-
self.kwargs = dict(kwargs)
28+
self.args = args
29+
self.kwargs = kwargs
3030
return self
3131

3232

3333
class TaskOutput(dict): # type: ignore[type-arg]
34-
def __init__(self, data: Dict[str, Any]) -> None:
35-
self._data = data
36-
super().__init__(data)
37-
3834
def __iter__(self) -> Iterator[Any]:
3935
output: List[Any] = []
40-
for _, v in self._data.items():
36+
for _, v in self.items():
4137
output.append(v)
4238
self._output_list = output
4339
self._index = 0

0 commit comments

Comments
 (0)