uwsgi.cache_set() not working in separate thread inside a mule process The Next CEO of Stack OverflowWhat is the difference between a process and a thread?Is there any way to kill a Thread?“implements Runnable” vs “extends Thread” in JavaHow do I update the GUI from another thread?What is thread safe or non-thread safe in PHP?What is a daemon thread in Java?How to use threading in Python?Multiprocessing vs Threading PythonHow do servlets work? Instantiation, sessions, shared variables and multithreadinguWSGI restarts attached processes without stopping old ones

Math-accent symbol over parentheses enclosing accented symbol (amsmath)

How did people program for Consoles with multiple CPUs?

Proper way to express "He disappeared them"

What does "Its cash flow is deeply negative" mean?

Make solar eclipses exceedingly rare, but still have new moons

The exact meaning of 'Mom made me a sandwich'

INSERT to a table from a database to other (same SQL Server) using Dynamic SQL

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

0 rank tensor vs 1D vector

How to install OpenCV on Raspbian Stretch?

What was the first Unix version to run on a microcomputer?

Is there always a complete, orthogonal set of unitary matrices?

Chain wire methods together in Lightning Web Components

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

Does Germany produce more waste than the US?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

How many extra stops do monopods offer for tele photographs?

How to avoid supervisors with prejudiced views?

Is it okay to majorly distort historical facts while writing a fiction story?

Why this way of making earth uninhabitable in Interstellar?

How do I align (1) and (2)?

Why do remote US companies require working in the US?

Running a General Election and the European Elections together



uwsgi.cache_set() not working in separate thread inside a mule process



The Next CEO of Stack OverflowWhat is the difference between a process and a thread?Is there any way to kill a Thread?“implements Runnable” vs “extends Thread” in JavaHow do I update the GUI from another thread?What is thread safe or non-thread safe in PHP?What is a daemon thread in Java?How to use threading in Python?Multiprocessing vs Threading PythonHow do servlets work? Instantiation, sessions, shared variables and multithreadinguWSGI restarts attached processes without stopping old ones










0















For experiment, I set up a cache uwsgi.cache_set('test', data) inside a mule process. The cache is set as expected.



Now I spawn a thread from which I can access that cache




Threading is enabled in uwsgi.ini:



[uwsgi]
threads = 4



in mule.py:



#Threaded function
def a_function():
uwsgi.cache_set('test', b'NOT OK') <- Nothing happens here
cache_return = uwsgi.cache_get('test') <- Returns b'OK' which means the cache did not overwrite the previous value.

if __name__ == '__main__':
cache = uwsgi.cache_set('test', b'OK') <- Works here
cache_return = uwsgi.cache_get('test') <- Return b'OK', as expected
t = Thread(target=a_function)
t.start()


The question is why does this happen and how do I set caches from inside a thread.










share|improve this question




























    0















    For experiment, I set up a cache uwsgi.cache_set('test', data) inside a mule process. The cache is set as expected.



    Now I spawn a thread from which I can access that cache




    Threading is enabled in uwsgi.ini:



    [uwsgi]
    threads = 4



    in mule.py:



    #Threaded function
    def a_function():
    uwsgi.cache_set('test', b'NOT OK') <- Nothing happens here
    cache_return = uwsgi.cache_get('test') <- Returns b'OK' which means the cache did not overwrite the previous value.

    if __name__ == '__main__':
    cache = uwsgi.cache_set('test', b'OK') <- Works here
    cache_return = uwsgi.cache_get('test') <- Return b'OK', as expected
    t = Thread(target=a_function)
    t.start()


    The question is why does this happen and how do I set caches from inside a thread.










    share|improve this question


























      0












      0








      0








      For experiment, I set up a cache uwsgi.cache_set('test', data) inside a mule process. The cache is set as expected.



      Now I spawn a thread from which I can access that cache




      Threading is enabled in uwsgi.ini:



      [uwsgi]
      threads = 4



      in mule.py:



      #Threaded function
      def a_function():
      uwsgi.cache_set('test', b'NOT OK') <- Nothing happens here
      cache_return = uwsgi.cache_get('test') <- Returns b'OK' which means the cache did not overwrite the previous value.

      if __name__ == '__main__':
      cache = uwsgi.cache_set('test', b'OK') <- Works here
      cache_return = uwsgi.cache_get('test') <- Return b'OK', as expected
      t = Thread(target=a_function)
      t.start()


      The question is why does this happen and how do I set caches from inside a thread.










      share|improve this question
















      For experiment, I set up a cache uwsgi.cache_set('test', data) inside a mule process. The cache is set as expected.



      Now I spawn a thread from which I can access that cache




      Threading is enabled in uwsgi.ini:



      [uwsgi]
      threads = 4



      in mule.py:



      #Threaded function
      def a_function():
      uwsgi.cache_set('test', b'NOT OK') <- Nothing happens here
      cache_return = uwsgi.cache_get('test') <- Returns b'OK' which means the cache did not overwrite the previous value.

      if __name__ == '__main__':
      cache = uwsgi.cache_set('test', b'OK') <- Works here
      cache_return = uwsgi.cache_get('test') <- Return b'OK', as expected
      t = Thread(target=a_function)
      t.start()


      The question is why does this happen and how do I set caches from inside a thread.







      python-3.x multithreading caching uwsgi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 16:42







      Temperosa

















      asked Mar 7 at 16:37









      TemperosaTemperosa

      4215




      4215






















          1 Answer
          1






          active

          oldest

          votes


















          0














          OK it seems like I used the wrong function (cache_set) instead of cache_update.




          uwsgi.cache_set(key, value[, expire, cache_name])



          Set a value in the cache. If the key is already set but not expired,
          it doesn’t set anything
          .






          uwsgi.cache_update(key, value[, expire, cache_name])


          Update a value in the cache. This always sets the key, whether it was
          already set before or not and whether it has expired or not.







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048752%2fuwsgi-cache-set-not-working-in-separate-thread-inside-a-mule-process%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            OK it seems like I used the wrong function (cache_set) instead of cache_update.




            uwsgi.cache_set(key, value[, expire, cache_name])



            Set a value in the cache. If the key is already set but not expired,
            it doesn’t set anything
            .






            uwsgi.cache_update(key, value[, expire, cache_name])


            Update a value in the cache. This always sets the key, whether it was
            already set before or not and whether it has expired or not.







            share|improve this answer



























              0














              OK it seems like I used the wrong function (cache_set) instead of cache_update.




              uwsgi.cache_set(key, value[, expire, cache_name])



              Set a value in the cache. If the key is already set but not expired,
              it doesn’t set anything
              .






              uwsgi.cache_update(key, value[, expire, cache_name])


              Update a value in the cache. This always sets the key, whether it was
              already set before or not and whether it has expired or not.







              share|improve this answer

























                0












                0








                0







                OK it seems like I used the wrong function (cache_set) instead of cache_update.




                uwsgi.cache_set(key, value[, expire, cache_name])



                Set a value in the cache. If the key is already set but not expired,
                it doesn’t set anything
                .






                uwsgi.cache_update(key, value[, expire, cache_name])


                Update a value in the cache. This always sets the key, whether it was
                already set before or not and whether it has expired or not.







                share|improve this answer













                OK it seems like I used the wrong function (cache_set) instead of cache_update.




                uwsgi.cache_set(key, value[, expire, cache_name])



                Set a value in the cache. If the key is already set but not expired,
                it doesn’t set anything
                .






                uwsgi.cache_update(key, value[, expire, cache_name])


                Update a value in the cache. This always sets the key, whether it was
                already set before or not and whether it has expired or not.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 18:03









                TemperosaTemperosa

                4215




                4215





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048752%2fuwsgi-cache-set-not-working-in-separate-thread-inside-a-mule-process%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович