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

Implements asyncio support for nirum compiler #164

Closed
wants to merge 4 commits into from

Conversation

Suckzoo
Copy link

@Suckzoo Suckzoo commented Aug 14, 2017

Supporting asyncio is configurable with support_async flag in package.toml.
To implement this option, I implemented boolean field handling in Package/metadata.hs.

If the support_async flag is set to true, my nirum fork creates another service module {className}_Async and put async def keyword to methods, instead of def keywords.

To implement tox unit tests, I created another fixture in test/nirum_fixture_async. It just contains a service with one bool field.

@@ -890,8 +905,8 @@ class {className}_Client($className):
et <- compileTypeExpression src errorTypeExpression
return $ Just [qq|('{toAttributeName' mn}', $et)|]
Nothing -> return Nothing
compileMethod :: Method -> CodeGen Code
compileMethod m@(Method mName params rtype _etype _anno) = do
compileMethod :: Bool -> Method -> CodeGen Code
Copy link
Contributor

Choose a reason for hiding this comment

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

Bool을 그대로 쓰기보다는 async 여부를 나타낼 수 있는 새로운 타입을 정의하는 것을 추천합니다.

name = "nirum"
email = "dev@nirum.org"

[targets]
Copy link
Contributor

Choose a reason for hiding this comment

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

이 줄은 불필요합니다.

service pong-service (
bool pong (),


Copy link
Contributor

Choose a reason for hiding this comment

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

이 여백은 불필요합니다.



def test_async_disabled():
service = PingService_Async()
Copy link
Contributor

Choose a reason for hiding this comment

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

support_async = false인 경우엔 아예 PingService_Async가 생성되지 않아야 하지 않을까 생각합니다. 어차피 생성된다고 해도 진짜 async 버전과 서로 인터페이스가 호환되지도 않을 테고요.

@Suckzoo
Copy link
Author

Suckzoo commented Aug 14, 2017

Python 3.4 does not supports async keywords. Needs to branch with sys.version.

@dahlia dahlia added cat:packaging Category: Nirum schema packaging (not compiler packaging) cmp:frontend Component: Compiler frontend (e.g., CLI, parser, AST) labels Aug 26, 2017
@dahlia dahlia force-pushed the master branch 13 times, most recently from 7d5a611 to 12a5ff2 Compare February 18, 2018 10:28
@achimnol
Copy link

It's 2018 — I think Python 3.4 support could be dropped since aiohttp now supports only Python 3.5.3+ and major Linux distros come with Python 3.5+ now.

@dahlia dahlia closed this Aug 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:packaging Category: Nirum schema packaging (not compiler packaging) cmp:frontend Component: Compiler frontend (e.g., CLI, parser, AST)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants