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

add a work-around to make the examples work on win+py3.6/3.7 #106

Merged
merged 8 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/blender/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ async def worker(ctx: WorkContext, tasks):
parser.set_defaults(log_file="blender-yapapi.log")
args = parser.parse_args()

utils.asyncio_fix()

enable_default_logger(log_file=args.log_file)
loop = asyncio.get_event_loop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a quick fix we may also consider:

if sys.platform == 'win32' and sys.version_info < (3, 8):
    asyncio.set_event_loop(asyncio.ProactorEventLoop())

instead of calling utils.asyncio_fix()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to go with a separate function in utils, I think the name needs to be improved to be more descriptive (e.g.: asyncio_windows_fix or even windows_event_loop_fix)

subnet = args.subnet_tag
Expand Down
11 changes: 11 additions & 0 deletions examples/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Utilities for yapapi example scripts."""
import argparse
import asyncio
import sys

TEXT_COLOR_RED = "\033[31;1m"
TEXT_COLOR_GREEN = "\033[32;1m"
Expand All @@ -21,3 +23,12 @@ def build_parser(description: str):
"--log-file", default=None, help="Log file for YAPAPI; default: %(default)s"
)
return parser


def asyncio_fix():
if sys.platform == "win32" and sys.version_info[0] == 3 and sys.version_info[1] <= 7:

class _WindowsEventPolicy(asyncio.events.BaseDefaultEventLoopPolicy):
_loop_factory = asyncio.windows_events.ProactorEventLoop

asyncio.set_event_loop_policy(_WindowsEventPolicy())
2 changes: 2 additions & 0 deletions examples/yacat/yacat.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ async def worker_find_password(ctx: WorkContext, tasks):

args = parser.parse_args()

utils.asyncio_fix()

enable_default_logger(log_file=args.log_file)

sys.stderr.write(
Expand Down
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 = "poetry.masonry.api"

[tool.poetry]
name = "yapapi"
version = "0.3.0"
version = "0.3.1-alpha.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd release it as 0.3.1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's make pre-release first for 0.3.1-alpha.0, then bump the version to 0.3.1 and do a release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipgolem @azawlocki actually, if, despite my opinion to the contrary, we didn't update the library itself, imvho, it didn't even require a release ...

description = "High-level Python API for the New Golem"
authors = ["Przemysław K. Rekucki <[email protected]>"]
license = "LGPL-3.0-or-later"
Expand Down