Skip to content

Conversation

@chrisrink10
Copy link
Member

Fixes #1179
Fixes #1181

@ikappaki
Copy link
Contributor

Hi @chrisrink10,

Both definitions look good. I've been using the following for async for, which seems simpler than using a loop. Is there a catch perhaps somewhere, in terms of coverage, expression or performance using a context manager?

(defmacro forasync
  [[var value] & body]
  `(let [~var ~value]
    (~'await (.__aenter__ ~var))
    (try
      ~@body
      (finally
        (~'await (.__aexit__ ~var nil nil nil))))))

Thanks

@chrisrink10
Copy link
Member Author

Both definitions look good. I've been using the following for async for, which seems simpler than using a loop. Is there a catch perhaps somewhere, in terms of coverage, expression or performance using a context manager?

I thought you wanted to have the async for loop?

@ikappaki
Copy link
Contributor

Both definitions look good. I've been using the following for async for, which seems simpler than using a loop. Is there a catch perhaps somewhere, in terms of coverage, expression or performance using a context manager?

I thought you wanted to have the async for loop?

Sorry, yes you're right, please ignore the above, that was a trivial async with impl.

@chrisrink10 chrisrink10 force-pushed the feature/async-macros branch from 97a1a98 to fd8e868 Compare April 11, 2025 01:20
@chrisrink10 chrisrink10 marked this pull request as ready for review April 11, 2025 01:21
@chrisrink10 chrisrink10 merged commit 88cfb0b into main Apr 11, 2025
12 checks passed
@chrisrink10 chrisrink10 deleted the feature/async-macros branch April 11, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for async iterators in seq functions Support for async with

2 participants