Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow warn level > 1 in tasks #90

Merged
merged 5 commits into from Sep 27, 2019
Merged

Allow warn level > 1 in tasks #90

merged 5 commits into from Sep 27, 2019

Conversation

@wch
Copy link
Collaborator

@wch wch commented Sep 26, 2019

This PR also makes pool work properly with later 1.0.0.

wch added 3 commits Sep 26, 2019
R/scheduler.R Outdated Show resolved Hide resolved
R/scheduler.R Outdated Show resolved Hide resolved
@wch
Copy link
Collaborator Author

@wch wch commented Sep 27, 2019

This PR works with the rc-v1.0.0 branch of later, but fails with the CRAN version (0.8.0). We'll need to make it compatible with both.

This is the error message:

 Error: Test failed: 'destroyObject: throws if onDestroy fails'
* (converted from warning) `{ ... }` generated a condition with class Rcpp::eval_error/C++Error/error/condition.
It is less fragile to test custom conditions with `class`
1: expect_error({
       poolReturn(b)
       later::run_now()
   }, regexp = paste0("Object of class MockPooledObj could not be ", "destroyed properly, but was successfully removed ", 
       "from pool.")) at :32
2: warn(paste0(act$lab, " generated a condition with class ", klass, ".\n", "It is less fragile to test custom conditions with `class`"))
3: warning(cnd)
4: withRestarts({
       .Internal(.signalCondition(cond, message, call))
       .Internal(.dfltWarn(message, call))
   }, muffleWarning = function() NULL)
5: withOneRestart(expr, restarts[[1L]])
6: doWithOneRestart(return(expr), restart) 
@wch
Copy link
Collaborator Author

@wch wch commented Sep 27, 2019

I just pushed a fix that makes it compatible with the old and new versions of later. The difference in behavior here is that the old version of later would pass the error object through, and so expect_error would receive an error object which has the classes "Rcpp::eval_error" "C++Error" "error" "condition", while the new version of later catches the original error and throws a new one, which has classes "Rcpp::exception" "C++Error" "error" "condition".

The testthat::expect_error function considers Rcpp::eval_errorto _not_ be "simple errors", but it does considerRcpp::exceptionobjects as simple errors. With non-simple errors,expect_error()wants aclassto be specified, otherwise it will throw an error. The change I made looks forclass="error"`, because that class is shared between both old and new versions.

For reference, this is the error object from the old version of later:

 $ message : chr "Evaluation error: (converted from warning) Object of class MockPooledObj could not be destroyed properly, but w"| __truncated__
 $ call    : language execCallbacks(timeoutSecs, all)
 $ cppstack: NULL
 - attr(*, "class")= chr [1:4] "Rcpp::eval_error" "C++Error" "error" "condition"

And from tne new version:

List of 3
 $ message : chr "Evaluation error: (converted from warning) Object of class MockPooledObj could not be destroyed properly, but w"| __truncated__
 $ call    : language execCallbacks(timeoutSecs, all, loop$id)
 $ cppstack:
  1 : 1   later.so                            0x000000010d05facd _Z11stack_tracePKci + 125
   2 : 2   later.so                            0x000000010d05f98c _ZN4Rcpp9exceptionC2EPKcb + 108
   3 : 3   later.so                            0x000000010d05b96c _ZN4Rcpp9exceptionC1EPKcb + 44
   4 : 4   later.so                            0x000000010d063ee3 _ZNK8Callback14invoke_wrappedEv + 755
   5 : 5   later.so                            0x000000010d074c23 _Z13execCallbacksdbi + 435
   6 : 6   later.so                            0x000000010d0584d8 _later_execCallbacks + 312
   7 : 7   libR.dylib                          0x0000000102b522fc R_doDotCall + 236
   8 : 8   libR.dylib                          0x0000000102b5f610 do_dotcall + 736
   9 : 9   libR.dylib                          0x0000000102baa6fe bcEval + 26830
   10 : 10  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   11 : 11  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   12 : 12  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   13 : 13  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   14 : 14  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   15 : 15  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   16 : 16  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   17 : 17  libR.dylib                          0x0000000102bc94ae getvar + 382
   18 : 18  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   19 : 19  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   20 : 20  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   21 : 21  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   22 : 22  libR.dylib                          0x0000000102bc94ae getvar + 382
   23 : 23  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   24 : 24  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   25 : 25  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   26 : 26  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   27 : 27  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   28 : 28  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   29 : 29  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   30 : 30  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   31 : 31  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   32 : 32  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   33 : 33  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   34 : 34  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   35 : 35  libR.dylib                          0x0000000102ba3d30 Rf_eval + 2608
   36 : 36  libR.dylib                          0x0000000102bc0618 do_begin + 280
   37 : 37  libR.dylib                          0x0000000102ba3a73 Rf_eval + 1907
   38 : 38  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   39 : 39  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   40 : 40  libR.dylib                          0x0000000102bc94ae getvar + 382
   41 : 41  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   42 : 42  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   43 : 43  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   44 : 44  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   45 : 45  libR.dylib                          0x0000000102bc94ae getvar + 382
   46 : 46  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   47 : 47  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   48 : 48  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   49 : 49  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   50 : 50  libR.dylib                          0x0000000102bc94ae getvar + 382
   51 : 51  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   52 : 52  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   53 : 53  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   54 : 54  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   55 : 55  libR.dylib                          0x0000000102bc94ae getvar + 382
   56 : 56  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   57 : 57  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   58 : 58  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   59 : 59  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   60 : 60  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   61 : 61  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   62 : 62  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   63 : 63  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   64 : 64  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   65 : 65  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   66 : 66  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   67 : 67  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   68 : 68  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   69 : 69  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   70 : 70  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   71 : 71  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   72 : 72  libR.dylib                          0x0000000102ba3d30 Rf_eval + 2608
   73 : 73  libR.dylib                          0x0000000102bc0618 do_begin + 280
   74 : 74  libR.dylib                          0x0000000102ba3a73 Rf_eval + 1907
   75 : 75  libR.dylib                          0x0000000102bc21f9 do_eval + 1289
   76 : 76  libR.dylib                          0x0000000102baa6fe bcEval + 26830
   77 : 77  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   78 : 78  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   79 : 79  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   80 : 80  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   81 : 81  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   82 : 82  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   83 : 83  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   84 : 84  libR.dylib                          0x0000000102bc94ae getvar + 382
   85 : 85  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   86 : 86  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   87 : 87  libR.dylib                          0x0000000102bbdef7 R_execClosure + 695
   88 : 88  libR.dylib                          0x0000000102bbd56f Rf_applyClosure + 703
   89 : 89  libR.dylib                          0x0000000102baa3b8 bcEval + 25992
   90 : 90  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   91 : 91  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   92 : 92  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   93 : 93  libR.dylib                          0x0000000102bc94ae getvar + 382
   94 : 94  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
   95 : 95  libR.dylib                          0x0000000102ba3613 Rf_eval + 787
   96 : 96  libR.dylib                          0x0000000102bbc94b forcePromise + 299
   97 : 97  libR.dylib                          0x0000000102bccd0b FORCE_PROMISE + 107
   98 : 98  libR.dylib                          0x0000000102bc94ae getvar + 382
   99 : 99  libR.dylib                          0x0000000102ba73f2 bcEval + 13762
 - attr(*, "class")= chr [1:4] "Rcpp::exception" "C++Error" "error" "condition"
@wch wch merged commit 3dbcf44 into master Sep 27, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@wch wch deleted the warn-level branch Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.