Code Monkey home page Code Monkey logo

Comments (3)

1k2s3v avatar 1k2s3v commented on August 22, 2024 1

Thank you for your response. But I already figure out the problem and even forget how =)) Sory did not close this issue earlier.
Have a nice day

from sqs-workers.

glsignal avatar glsignal commented on August 22, 2024 1

Hi there 🙂 I happened to have encountered the same problem as originally mentioned (TypeError: cannot pickle 'module' object)

I was wondering if you had any ways of helping to figure this out, whether it's an issue with my environment or implementation?

So far I've tried the minimal code mentioned in #16 (comment) and it still produces the problem. It's possible to avoid this with multiprocessing.set_start_method("fork") however that seems to present other issues affecting stability (at least for me, on this mac)

Calling something like this from the python repl (based on what the process_queues implementation does) will also produce the exception, I'm just at the limits of where to look further into detail as a relative newbie to python.

>>> import pickle
>>> from queue_handlers import sqs
>>> fn = sqs.queue("email").process_queue
>>> fn
<bound method GenericQueue.process_queue of RawQueue(name='email', backoff_policy=<sqs_workers.backoff_policies.ExponentialBackoff object at 0x10d630710>, batching_policy=<sqs_workers.batching.NoBatching object at 0x10d5e6ad0>, processor=<function send_email at 0x10dcb91c0>)>
>>> pickle.dumps(fn)
...the computer screams into the void ...
TypeError: cannot pickle 'module' object

This is with sqs-workers = 0.5.11 on python 3.11

If you have any tips for investigating problems like this, I'd appreciate any pointers or direction!
Like the original reporter, I too hope you have (or are already having) a nice day 😄

from sqs-workers.

Schnouki avatar Schnouki commented on August 22, 2024

Hey @1k2s3v, sorry for the delay.
Which version of sqs-workers are you using?

Could you please try to split your code in 2 files:

# queue_handlers.py
from sqs_workers import SQSEnv, create_standard_queue

sqs = SQSEnv()

create_standard_queue(sqs, "emails")
queue = sqs.queue("emails")

@queue.processor("send_email")
def send_email(to, subject, body):
    print('asd')

queue.add_job("send_email", to="[email protected]", subject="Hello world", body="hello world")
# processor.py
from queue_handlers import sqs

def run():
    sqs.process_queues()

if __name__ == "__main__":
    run()

and run python processor.py?

from sqs-workers.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.