Prevent “invoked too many times per second” error in Google Apps Script

I have a Google spreadsheet consisting of different months on each tab. Every month, I add a new tab and another 50-75 rows. There are many tabs. There is a cell on each row which calls a custom function, like this:

=myFunction(A1) 

The problem I am having is that I am getting the following error:

error: Script invoked too many times per second for this Google user account.

What can I do to prevent this error from occurring?

Is the problem because there are too many tabs, or too many rows per tab?

There must be a way to prevent the function from having to run more than once.


Here is a shortened version of the function that is called:

function myFunction(expense) { if (   InStr(1,expense,"CPC SCP") ||   InStr(1,expense,"CPC/SCP") ||   InStr(1,expense,"xxxx")   )   { category = "5530 - Postage Expense" }     else if (   InStr(1,expense,"PRE-AUTHORIZED PAYMENT") ||   InStr(1,expense,"xxx ")   )   { category = "9999 - Payment" }     else if (   InStr(1,expense,"PURCHASE INTEREST") ||   InStr(1,expense,"RETURNED PAYMENT FEE") ||   InStr(1,expense,"xxxx")   )   { category = "5070 - Bank Charges" }   else { category = "Not Sure" }  return category;    }  

Code invoked too many times

My goal is pretty simple: take the value in column U and check if it’s within particular ranges. If it’s 1–100, put a 1 in column A. If it’s 101–200, put a 2 in column A. The problem is, I have almost 2000 rows of numbers in column U. Putting =function(U2) in each cell in column A results in a

Script invoked too many times per second

error, and adding Utilities.sleep(500) at the end doesn’t help either. Here’s my code so far. Please excuse the ugliness, as I’m a very beginner programmer.

function assignBoxNumber(sgNumber) {   if(sgNumber>=1 && sgNumber<=71) {     return "1"   }   if(sgNumber==72) {     return "1 and 2"   }   if(sgNumber>=73 && sgNumber<=125) {     return "2"   }   if(sgNumber==126) {     return "2 and 3"   }   if(sgNumber>=127 && sgNumber<=202) {     return "3"   }   if(sgNumber>=207 && sgNumber<=269) {     return "4"   }   if(sgNumber>=270 && sgNumber<=333) {     return "5"   }   if(sgNumber>=334 && sgNumber<=433) {     return "6"   }   if(sgNumber>=434 && sgNumber<=497) {     return "7"   }   if(sgNumber>=498 && sgNumber<=560) {     return "8"   }   if(sgNumber>=561 && sgNumber<=627) {     return "9"   }   if(sgNumber>=628 && sgNumber<=691) {     return "10"   }   if(sgNumber>=692 && sgNumber<=791) {     return "11"   }   if(sgNumber>=792 && sgNumber<=872) {     return "12"   }   if(sgNumber>=874 && sgNumber<=955) {     return "13"   }   if(sgNumber>=956 && sgNumber<=1019) {     return "14"   }   else {     return "Error: No box location!"   }   Utilities.sleep(500) } 

Right thread implementation in frequently invoked method

I am fresh in c++

But actually what I am interested in :

I have such method

void VideoRender::updateData(const std::string &i_obj_path, const std::string &i_pngPath, const uint i_subIndex) {     std::shared_ptr<FrameManager> container = std::make_shared<FrameManager>();      std::thread th1(&VideoRender::thread_task1, this, i_obj_path.c_str(), i_subIndex, container);     std::thread th2(&VideoRender::thread_task2, this, i_pngPath, container);      th1.join();     th2.join();      fifo.enqueue(container); } 

As you can see, this method is executing 2 task in 2 different threads and then join them. I invoke this method 20 times per second.

What bothers me: that 20 times per second I create 2 threads…

Question is: if this implementation in c++ looks ok? Because I think I should to use something like ThreadPool or some Handler that will run in another thread and I will push the task‘s there…

If am I right?

Right thread implementation in frequently invoked method

I am fresh in c++

But actually what I am interested in :

I have such method

void VideoRender::updateData(const std::string &i_obj_path, const std::string &i_pngPath, const uint i_subIndex) {     std::shared_ptr<FrameManager> container = std::make_shared<FrameManager>();      std::thread th1(&VideoRender::thread_task1, this, i_obj_path.c_str(), i_subIndex, container);     std::thread th2(&VideoRender::thread_task2, this, i_pngPath, container);      th1.join();     th2.join();      fifo.enqueue(container); } 

As you can see, this method is executing 2 task in 2 different threads and then join them. I invoke this method 20 times per second.

What bothers me: that 20 times per second I create 2 threads…

Question is: if this implementation in c++ looks ok? Because I think I should to use something like ThreadPool or some Handler that will run in another thread and I will push the task‘s there…

If am I right?

how to interact(provide inputs and read output) with command invoked by batch file using java

I am trying to run a bat file which invokes a Java class, I want to continue interacting with command window by providing inputs and reading output from command window. But I am only able to read the first line of the command prompt and not aware how to interact with it further. on executing batch file it prompts us for a file name, once file name entered, it ask for other details

Tried using process builder and plexus util, I am not able to figure out how to run the second command after executing first one.

The below images is if I do manually, first it prompts me for file directory, enter image description here

Then it prompts me for date enter image description here

Tried using the below code

public class plexus {

public plexus() {     String batfile = "regression-test-runner-steadfast.bat";     String directory = "C:\Dev\temp\IOS-automation-test\Steadfast-UAT-Regression-Test-Runner-Client-dist";     try {         runProcess(batfile, directory);     } catch (CommandLineException e) {         e.printStackTrace();     } }  public void runProcess(String batfile, String directory) throws CommandLineException {      Commandline commandLine = new Commandline();      File executable = new File(directory + "/" +batfile);     commandLine.setWorkingDirectory(directory);     commandLine.setExecutable(executable.getAbsolutePath());     commandLine.createArg().setValue("C:\Users\U399526\Desktop\SVU_XML\Scenario 1");      WriterStreamConsumer systemOut = new WriterStreamConsumer(             new OutputStreamWriter(System.out));      WriterStreamConsumer systemErr = new WriterStreamConsumer(             new OutputStreamWriter(System.out));      int returnCode = CommandLineUtils.executeCommandLine(commandLine, systemOut, systemErr);       if (returnCode != 0) {         System.out.println("Something Bad Happened!");     } else {         System.out.println("Taaa!! ddaaaaa!!");     }; }  public static void main(String[] args) {     new plexus(); } 

}

MySql Error: Can’t update table in stored function/trigger because it is already used by statement which invoked this stored function/trigger

Quiero realizar un trigger que elimine el registro de una tabla llamada stock al momento que en la tabla cotizacion el campo estatus cambie a 1 tengo el siguiente codigo

DELIMITER $ $

CREATE TRIGGER elimina_maquina BEFORE INSERT ON cotizacion FOR EACH ROW DELETE a1, a2 FROM cotizacion AS a1 INNER JOIN stock AS a2 WHERE a1.estatus=1 AND a1.id_serie=a2.id_serie; $ $ DELIMITER ;

pero el error que me muestra es el del titulo

MySql Error: Can’t update table in stored function/trigger because it is already used by statement which invoked this stored function/trigger

aqui tengo una captura de la relacion de la tablaintroducir la descripción de la imagen aquí

Is hook_node_view() invoked every time?

I wrote a custom module that records page views. So each time a user views a node, it creates an entry in a database table. Essentially I wanted my own custom statistics module.

The problem is, it’s only called once. I would assume some kind of caching is applied to this function. I have this:

function hook_node_view( $  node,  $  display, $  view_mode, $  langcode) {     $  nodeObject = $  node['#node'];      $  insert = array(         'created'    => REQUEST_TIME,         'nid'        => $  nodeObject->id(),         'uid'        => \Drupal::currentUser()->id(),         'ip'         => \Drupal::request()->getClientIp(),         'session_id' => session_id(),     );      db_insert('node_view_log')     ->fields($  insert)     ->execute();  } 

But it is only called once per node, and not each time the node is viewed. Any idea as to why this is happening? Is there a way to turn of caching for this function only? Or is there perhaps a better place to log page views?

How often can a trait be invoked in a game?

The question is pretty much what the title says. I understand that you can only invoke a trait once per action, but I can’t find anything that says how often per game a single trait can be invoked. Is there a limit to that, or is it essentially “Invoke the trait as often as the Loremaster allows?”

As an example: My Loremaster has stated that if I have the Keen-Eyed distinctive feature, that by the rules I can only use the distinctive feature once in a session, and that I get new uses of my distinctive feature in the next session. Is that correct according to the rules?

If possible, could someone write down whatever page number in which book or document would answer this question?

By pass call to void method, invoked from inside a void method

I am having a class:

class A{ public void methodA() { new B().methodB("string"); ---- ---- } }   class B { public void methodB(String s) { --- --- } } 

I need to write a mock, so that I can bypass call to methodB(), inside class A’s methodA().

I tried doing: //B b = PowerMockito.spy(new B());

//PowerMockito.doNothing().when(b).methodB(null);

Also tried spying:

//B b = Mockito.spy(new B()); //Mockito.doNothing().when(b).methodB(“dummy”);

But nothing working, and the methodB(), is getting invoked in my unit test.