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

Inconsistent data types within library #411

Open
adityaraj-28 opened this issue Aug 2, 2023 · 0 comments
Open

Inconsistent data types within library #411

adityaraj-28 opened this issue Aug 2, 2023 · 0 comments

Comments

@adityaraj-28
Copy link

adityaraj-28 commented Aug 2, 2023

While working with sqlalchemy backend for DB and strategy worker and Kafka backend for spider. Found out that in the file frontera.worker.server.WorkerJsonRpcService there is this function

class WorkerJsonRpcService(JsonRpcService):
    def __init__(self, worker, settings):
        root = RootResource()
        root.putChild('status', StatusResource(worker))
        root.putChild('jsonrpc', WorkerJsonRpcResource(worker))
        JsonRpcService.__init__(self, root, settings)
        self.worker = worker

And in the Resource class which the class where the putChild function is defined, I saw this line

    def putChild(self, path: bytes, child: IResource) -> None:
        if not isinstance(path, bytes):
            raise TypeError(f"Path segment must be bytes, but {path!r} is {type(path)}")

So it always throws the TypeError as we send a string as first param in putChild and accept it to be bytes.
Changing the code to below works, but is not elegant as I don't wan't to modify library code just for this usecase.

root.putChild(b'status', StatusResource(worker))
root.putChild(b'jsonrpc', WorkerJsonRpcResource(worker))

Happy to raise a PR post discussion !

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

No branches or pull requests

1 participant