Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Yielding is not allowed within a C or metamethod call

New Here ,
Apr 27, 2012 Apr 27, 2012

The way I'm developing my plug in is that I'm creating individual modules, testing those modules and then integrating the modules into my plugin. The individual modules work. However, I have a problem when I try to integrate.

I'm using an anonymous function to call a function when a user presses a button. That function calls another lua file (is that a module?) If I place the require statement at the top of the file I receive the Yielding is not allowed within a C or metamethod call error.

However, if I place the require statement within the function that specifically requires accessing the lua file then I don't receive the error. Clearly, I don't understand what's going on. Can anyone explain what is happening here?

Thanks!

TOPICS
SDK
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 27, 2012 Apr 27, 2012

The problem is when I call the LrHttp.post function. That's when the yield error is being thrown.

The error message "Yielding is not allowed within a C or metamethod call" arises when you call a function or method that needs to be invoked from a task created by LrTasks or LrFunctionContext.postAsyncTaskWithContext.

In this case, the LrHttp functions have to be called from a task.  The SDK documentation is pretty good (but not perfect) about calling out which functions and methods have to be calle

...
Translate
LEGEND ,
Apr 27, 2012 Apr 27, 2012

Does your module have executable code in the body of it? If so, consider putting it in a function, then call the function when you are ready, so nothing gets executed when the module is "require'd".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2012 Apr 27, 2012

Hey Rob,

Thanks for helping me with this. Since this is so new to me, I'm all over the place and I'm having trouble even understanding what my problems are 🙂

Anyway, here's where I'm at:

I have a button in sectionsForTopOfDialog. I have changed the action to be action = function() .... end

When I press the button the function is called. The problem is when I call the LrHttp.post function. That's when the yield error is being thrown.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2012 Apr 27, 2012

The problem is when I call the LrHttp.post function. That's when the yield error is being thrown.

The error message "Yielding is not allowed within a C or metamethod call" arises when you call a function or method that needs to be invoked from a task created by LrTasks or LrFunctionContext.postAsyncTaskWithContext.

In this case, the LrHttp functions have to be called from a task.  The SDK documentation is pretty good (but not perfect) about calling out which functions and methods have to be called from a task. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2012 Apr 27, 2012
LATEST

Thanks! Of course, that was my problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2012 Apr 27, 2012

try:

action = function( button )

     -- start task

end

instead of:

action = "call a function that starts a task"

In the first case, you are assigning a function value to action which will get called when the user clicks the button.

In the second case, you are calling a function and assigning the return value to action.

eh?

R

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines