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

[BUG] State is changing in Stateless actor #67

Open
ehsanmok opened this issue Aug 27, 2023 · 2 comments · May be fixed by #69
Open

[BUG] State is changing in Stateless actor #67

ehsanmok opened this issue Aug 27, 2023 · 2 comments · May be fixed by #69
Labels
bug Something isn't working
Milestone

Comments

@ehsanmok
Copy link

ehsanmok commented Aug 27, 2023

Describe the bug

Started playing with the library, please correct me if I'm wrong but state should not change in Stateless actor and following ideally should not work like that or at least should warn in runtime.

To Reproduce

To help us to reproduce this bug, please provide information below:

import asyncio
import xoscar as xo
import nest_asyncio
nest_asyncio.apply()

class Counter(xo.StatelessActor):  # <-- intentional to check it there's at least a runtime warning!
    count = 0

    def inc(self):
        self.count += 1
        print(self.count)

async def main():
    address = "localhost:9999"
    await xo.create_actor_pool(address=address, n_process=1)
    actor = await xo.create_actor(
        Counter,
        address=address,
        uid="1",
    )
    tasks = [actor.inc() for _ in range(10)]
    await asyncio.gather(*tasks)
    await xo.destroy_actor(actor)

asyncio.run(main())

outputs

1
2
3
4
5
6
7
8
9
10
  1. Your Python version: 3.10
  2. The version of Xoscar you use: latest 0.1
  3. Versions of crucial packages, such as numpy, scipy and pandas
  4. Full stack of the error.
  5. Minimized code to reproduce the error.

Expected behavior

A clear and concise description of what you expected to happen.

Additional context

Add any other context about the problem here.

@XprobeBot XprobeBot added the bug Something isn't working label Aug 27, 2023
@XprobeBot XprobeBot added this to the v0.1.1 milestone Aug 27, 2023
@qinxuye
Copy link
Contributor

qinxuye commented Aug 28, 2023

Good try, let's check what's going on there.

@codingl2k1
Copy link
Contributor

The StatelessActor is not for the actor has no state changes.

  • Actor - All the methods are guarded by an asyncio.locks.Lock.
  • StatelessActor - All the methods are called directly.

Sorry for the misunderstanding. We will fix this issue in the next release.

@codingl2k1 codingl2k1 linked a pull request Aug 28, 2023 that will close this issue
2 tasks
@XprobeBot XprobeBot modified the milestones: v0.1.1, v0.1.2 Sep 8, 2023
@XprobeBot XprobeBot modified the milestones: v0.3.0, v0.3.1, v0.3.2, v0.3.3 Jul 10, 2024
@XprobeBot XprobeBot modified the milestones: v0.3.3, v0.3.4 Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants