RE: lots of ReadConflictErrors

"Boylan, Ross" <[email protected]>
Newsgroups gmane.comp.web.zope.zodb
Message-ID <[email protected]>
Ah, that goes a good way to meeting my concern.  But isn't that a pretty unusual, i.e., likely to be surprising and confusing, way to use a decorator, and, for that matter, the function definition that follows?  Function definitions don't usually execute the code of the function.

Realizing now that functions can be defined inline, i.e., nested, one could have the more verbose but, I think, more conventional, 
  def mainFn():

      @transaction.manager
      def step1():
            # some code for your first transaction
     step1()

      @transaction.manager
      def step2():
          # and for the second
     step2()

Ross
________________________________________
From: [email protected] [[email protected]] on behalf of Jim Fulton [[email protected]]
Sent: Friday, October 07, 2016 4:01 PM
To: Boylan, Ross
Cc: Jim Fulton; zodb ‎[[email protected]]‎
Subject: Re: [ZODB] lots of ReadConflictErrors

On Fri, Oct 7, 2016 at 5:56 PM, Boylan, Ross <[email protected]> wrote:
> Yes; that's what I meant by the "thread you mention".  It seems to me it would lead to this kind of pattern (using your proposed decorator name):
>
> @transaction.manager.run
> def step1():
>     # some code for your first transaction
>
> @transaction.manager.run
> def step2():
>     # and for the second
>
> #etc
>
> def mainFn():
>     # so some stuff
>     step1()
>     # more computations here
>     step2()
>     # etc
>

Nope:

  def mainFn():

      @transaction.manager.run
      def step1():
            # some code for your first transaction

      @transaction.manager.run
      def step2():
          # and for the second

Or even:


  def mainFn():

      @transaction.manager.run
      def _():
            # some code for your first transaction

      @transaction.manager.run
      def _():
          # and for the second

The decorator *run*s the decorated function.

Jim

--
Jim Fulton
http://jimfulton.info

-- 
You received this message because you are subscribed to the Google Groups "zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.